Reputation: 1
I'm trying to understand how workflows work in UKBiobank's Research Analysis Platform (RAP). I wanted to create a sample workflow of saving just the head of an input dataset and saving this subsetted dataset in a directory. I'm getting an error pertaining to the 'command' section of my WDL script.
WDL script:
workflow save_head_workflow {
input {
File input_file # Input dataset file
Int num_rows = 5 # Number of rows to return (default is 5)
}
call saveHead {
input:
input_file = input_file,
num_rows = num_rows
}
output {
File output_file = saveHead.output_file
}
}
task saveHead {
input {
File input_file # Input dataset file
Int num_rows # Number of rows to extract
}
command {
python save_head.py --input ${input_file} --rows ${num_rows} --output output_head.csv
}
output {
File output_file = "output_head.csv"
}
runtime {
docker: "python:3.9-slim" # Lightweight Docker image with Python 3.9
}
}
save_head.py (the python script mentioned in the command in the above section):
import pandas as pd
import argparse
def save_head(input_file, num_rows, output_file):
"""
Reads a dataset and saves the first `num_rows` rows to the output file.
Args:
input_file (str): Path to the input file.
num_rows (int): Number of rows to save.
output_file (str): Path to the output file.
"""
# Read the dataset
df = pd.read_csv(input_file, sep=None, engine="python") # Auto-detect delimiter (CSV or TSV)
# Extract the head
head_df = df.head(num_rows)
# Save the head to the output file
head_df.to_csv(output_file, index=False)
print(f"Saved the first {num_rows} rows to {output_file}")
My json file indicating the input dataset:
{
"return_head_workflow.input_file": "/mnt/project/Participant_table.csv",
"return_head_workflow.num_rows": 5
}
The error that I get is somewhat like (the error passage is long but below is ultimately the error I believe: Caused by: wdlTools.syntax.SyntaxException: section command appears 0 times, it must appear exactly once at 18:0-50:1 in /home/dnanexus/return_head.wdl
Could anyone help me understand if there was anything wrong in the script(s) and kindly rectify them? Thanks in advance!
Upvotes: 0
Views: 28