Skip to content

Commit

Permalink
Added writing output_schema and count_lines.sh when initializing a pi…
Browse files Browse the repository at this point in the history
…peline interface #418
  • Loading branch information
donaldcampbelljr committed Oct 12, 2023
1 parent a6f5bbe commit f8a93fc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions looper/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
"DEBUG_JOBS",
"DEBUG_COMMANDS",
"DEBUG_EIDO_VALIDATION",
"LOOPER_GENERIC_OUTPUT_SCHEMA",
"LOOPER_GENERIC_COUNT_LINES",
]

FLAGS = ["completed", "running", "failed", "waiting", "partial"]
Expand Down Expand Up @@ -206,6 +208,8 @@ def _get_apperance_dict(type, templ=APPEARANCE_BY_FLAG):
SUBMISSION_FAILURE_MESSAGE = "Cluster resource failure"
LOOPER_DOTFILE_NAME = "." + LOOPER_KEY + ".yaml"
LOOPER_GENERIC_PIPELINE = "pipeline_interface.yaml"
LOOPER_GENERIC_OUTPUT_SCHEMA = "output_schema.yaml"
LOOPER_GENERIC_COUNT_LINES = "count_lines.sh"
POSITIONAL = [PEP_CONFIG_FILE_KEY, "command"]
SELECTED_COMPUTE_PKG = "package"
EXTRA_KEY = "_cli_extra"
Expand Down
35 changes: 34 additions & 1 deletion looper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def init_generic_pipeline():
# Destination one level down from CWD in pipeline folder
dest_file = os.path.join(os.getcwd(), "pipeline", LOOPER_GENERIC_PIPELINE)

# Determine Generic Pipeline Interface
# Create Generic Pipeline Interface
generic_pipeline_dict = {
"pipeline_name": "default_pipeline_name",
"pipeline_type": "sample",
Expand All @@ -355,6 +355,39 @@ def init_generic_pipeline():
f"Pipeline interface file already exists `{dest_file}`. Skipping creation.."
)

# Create Generic Output Schema
dest_file = os.path.join(os.getcwd(), "pipeline", LOOPER_GENERIC_OUTPUT_SCHEMA)
generic_output_schema_dict = {
"pipeline_name": "default_pipeline_name",
"samples": {
"number_of_lines": {
"type": "integer",
"description": "Number of lines in the input file.",
}
},
}
# Write file
if not os.path.exists(dest_file):
with open(dest_file, "w") as file:
yaml.dump(generic_output_schema_dict, file)
print(f"Output schema successfully created at: {dest_file}")
else:
print(f"Output schema file already exists `{dest_file}`. Skipping creation..")

# Create Generic countlines.sh
dest_file = os.path.join(os.getcwd(), "pipeline", LOOPER_GENERIC_COUNT_LINES)
shell_code = """#!/bin/bash
linecount=`wc -l $1 | sed -E 's/^[[:space:]]+//' | cut -f1 -d' '`
pipestat report -r $2 -i 'number_of_lines' -v $linecount -c $3
echo "Number of lines: $linecount"
"""
if not os.path.exists(dest_file):
with open(dest_file, "w") as file:
file.write(shell_code)
print(f"count_lines.sh successfully created at: {dest_file}")
else:
print(f"count_lines.sh file already exists `{dest_file}`. Skipping creation..")

return True


Expand Down

0 comments on commit f8a93fc

Please sign in to comment.