diff --git a/pipestat/parsed_schema.py b/pipestat/parsed_schema.py index ed4ea6c8..f8830efc 100644 --- a/pipestat/parsed_schema.py +++ b/pipestat/parsed_schema.py @@ -95,10 +95,16 @@ def __init__(self, data: Union[Dict[str, Any], Path, str]) -> None: self._pipeline_name = data["properties"].pop(SCHEMA_PIPELINE_NAME_KEY, None) + # Two passes for sample-data as it is now nested under items per #204 sample_data = _safe_pop_one_mapping( subkeys=["samples"], data=data["properties"], info_name="sample-level", + mappingkey="items", + ) + sample_data = _safe_pop_one_mapping( + data=sample_data, + info_name="sample-level", mappingkey="properties", ) diff --git a/tests/data/output_schema.yaml b/tests/data/output_schema.yaml index d4ecbc1e..01f83fff 100644 --- a/tests/data/output_schema.yaml +++ b/tests/data/output_schema.yaml @@ -4,9 +4,11 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - result_name: - type: string - description: "ResultName" + type: array + items: + type: object + properties: + result_name: + type: string + description: "ResultName" diff --git a/tests/data/output_schema_as_JSON_schema.yaml b/tests/data/output_schema_as_JSON_schema.yaml index 64582f20..d8cc84f4 100644 --- a/tests/data/output_schema_as_JSON_schema.yaml +++ b/tests/data/output_schema_as_JSON_schema.yaml @@ -4,54 +4,56 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - number_of_things: - type: integer - description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit." - output_image: - $ref: "#/$defs/image" - description: "This an output image" - output_file: - $ref: "#/$defs/file" - description: "This a path to the output image" - collection_of_images: - type: array - description: A collection of images. - items: + type: array + items: + type: object + properties: + number_of_things: + type: integer + description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit." + output_image: + $ref: "#/$defs/image" + description: "This an output image" + output_file: + $ref: "#/$defs/file" + description: "This a path to the output image" + collection_of_images: + type: array + description: A collection of images. + items: + type: object + properties: + prop1: + $ref: "#/$defs/file" + description: An example file. + nested_object: type: object + description: An object containing output file and image. properties: - prop1: + example_property_1: $ref: "#/$defs/file" description: An example file. - nested_object: - type: object - description: An object containing output file and image. - properties: - example_property_1: - $ref: "#/$defs/file" - description: An example file. - example_property_2: - $ref: "#/$defs/image" - description: An example image. - output_file_nested_object: - type: object - description: First Level - properties: - example_property_1: - type: object - description: Second Level - properties: - third_level_property_1: - $ref: "#/$defs/file" - description: Third Level - example_property_2: - type: object - description: Second Level - properties: - third_level_property_1: - $ref: "#/$defs/file" - description: Third Level + example_property_2: + $ref: "#/$defs/image" + description: An example image. + output_file_nested_object: + type: object + description: First Level + properties: + example_property_1: + type: object + description: Second Level + properties: + third_level_property_1: + $ref: "#/$defs/file" + description: Third Level + example_property_2: + type: object + description: Second Level + properties: + third_level_property_1: + $ref: "#/$defs/file" + description: Third Level $defs: image: type: object diff --git a/tests/data/output_schema_html_report.yaml b/tests/data/output_schema_html_report.yaml index 46a88e7d..f1dd0eda 100644 --- a/tests/data/output_schema_html_report.yaml +++ b/tests/data/output_schema_html_report.yaml @@ -19,26 +19,28 @@ properties: type: boolean description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras pharetra." samples: - type: object - properties: - smooth_bw: - path: "aligned_{genome}/{sample_name}_smooth.bw" - type: string - description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec cursus nulla." - aligned_bam: - path: "aligned_{genome}/{sample_name}_sort.bam" - type: string - description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ipsum erat, porta in condimentum viverra, pellentesque in nisl. Nulla rhoncus nibh est, quis malesuada diam suscipit at. In ut diam." - peaks_bed: - path: "peak_calling_{genome}/{sample_name}_peaks.bed" - type: string - description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec cursus nulla." - output_file: - $ref: "#/$defs/file" - description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec cursus nulla." - output_image: - $ref: "#/$defs/image" - description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras pharetra." + type: array + items: + type: object + properties: + smooth_bw: + path: "aligned_{genome}/{sample_name}_smooth.bw" + type: string + description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec cursus nulla." + aligned_bam: + path: "aligned_{genome}/{sample_name}_sort.bam" + type: string + description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ipsum erat, porta in condimentum viverra, pellentesque in nisl. Nulla rhoncus nibh est, quis malesuada diam suscipit at. In ut diam." + peaks_bed: + path: "peak_calling_{genome}/{sample_name}_peaks.bed" + type: string + description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec cursus nulla." + output_file: + $ref: "#/$defs/file" + description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce nec cursus nulla." + output_image: + $ref: "#/$defs/image" + description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras pharetra." $defs: image: type: object diff --git a/tests/data/sample_output_schema.yaml b/tests/data/sample_output_schema.yaml index 3211ccdd..eb7bbd2d 100644 --- a/tests/data/sample_output_schema.yaml +++ b/tests/data/sample_output_schema.yaml @@ -4,30 +4,32 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - number_of_things: - type: integer - description: "Number of things" - percentage_of_things: - type: number - description: "Percentage of things" - name_of_something: - type: string - description: "Name of something" - switch_value: - type: boolean - description: "Is the switch on or off" - output_file: - $ref: "#/$defs/file" - description: "This a path to the output file" - output_image: - $ref: "#/$defs/image" - description: "This a path to the output image" - md5sum: - type: string - description: "MD5SUM of an object" - highlight: true + type: array + items: + type: object + properties: + number_of_things: + type: integer + description: "Number of things" + percentage_of_things: + type: number + description: "Percentage of things" + name_of_something: + type: string + description: "Name of something" + switch_value: + type: boolean + description: "Is the switch on or off" + output_file: + $ref: "#/$defs/file" + description: "This a path to the output file" + output_image: + $ref: "#/$defs/image" + description: "This a path to the output image" + md5sum: + type: string + description: "MD5SUM of an object" + highlight: true $defs: image: type: object diff --git a/tests/data/sample_output_schema__with_project_with_samples_with_status.yaml b/tests/data/sample_output_schema__with_project_with_samples_with_status.yaml index e5d48a1c..e70d63ec 100644 --- a/tests/data/sample_output_schema__with_project_with_samples_with_status.yaml +++ b/tests/data/sample_output_schema__with_project_with_samples_with_status.yaml @@ -19,20 +19,22 @@ properties: type: boolean description: "Is the switch on or off" samples: - type: object - properties: - smooth_bw: - path: "aligned_{genome}/{sample_name}_smooth.bw" - type: string - description: "A smooth bigwig file" - aligned_bam: - path: "aligned_{genome}/{sample_name}_sort.bam" - type: string - description: "A sorted, aligned BAM file" - peaks_bed: - path: "peak_calling_{genome}/{sample_name}_peaks.bed" - type: string - description: "Peaks in BED format" + type: array + items: + type: object + properties: + smooth_bw: + path: "aligned_{genome}/{sample_name}_smooth.bw" + type: string + description: "A smooth bigwig file" + aligned_bam: + path: "aligned_{genome}/{sample_name}_sort.bam" + type: string + description: "A sorted, aligned BAM file" + peaks_bed: + path: "peak_calling_{genome}/{sample_name}_peaks.bed" + type: string + description: "Peaks in BED format" status: type: object properties: diff --git a/tests/data/sample_output_schema__with_project_with_samples_without_status.yaml b/tests/data/sample_output_schema__with_project_with_samples_without_status.yaml index 649abdaa..4a44d4ce 100644 --- a/tests/data/sample_output_schema__with_project_with_samples_without_status.yaml +++ b/tests/data/sample_output_schema__with_project_with_samples_without_status.yaml @@ -19,17 +19,19 @@ properties: type: boolean description: "Is the switch on or off" samples: - type: object - properties: - smooth_bw: - path: "aligned_{genome}/{sample_name}_smooth.bw" - type: string - description: "A smooth bigwig file" - aligned_bam: - path: "aligned_{genome}/{sample_name}_sort.bam" - type: string - description: "A sorted, aligned BAM file" - peaks_bed: - path: "peak_calling_{genome}/{sample_name}_peaks.bed" - type: string - description: "Peaks in BED format" + type: array + items: + type: object + properties: + smooth_bw: + path: "aligned_{genome}/{sample_name}_smooth.bw" + type: string + description: "A smooth bigwig file" + aligned_bam: + path: "aligned_{genome}/{sample_name}_sort.bam" + type: string + description: "A sorted, aligned BAM file" + peaks_bed: + path: "peak_calling_{genome}/{sample_name}_peaks.bed" + type: string + description: "Peaks in BED format" diff --git a/tests/data/sample_output_schema__without_project_with_samples_with_status.yaml b/tests/data/sample_output_schema__without_project_with_samples_with_status.yaml index 577f7ec6..bf76a542 100644 --- a/tests/data/sample_output_schema__without_project_with_samples_with_status.yaml +++ b/tests/data/sample_output_schema__without_project_with_samples_with_status.yaml @@ -4,20 +4,22 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - smooth_bw: - path: "aligned_{genome}/{sample_name}_smooth.bw" - type: string - description: "A smooth bigwig file" - aligned_bam: - path: "aligned_{genome}/{sample_name}_sort.bam" - type: string - description: "A sorted, aligned BAM file" - peaks_bed: - path: "peak_calling_{genome}/{sample_name}_peaks.bed" - type: string - description: "Peaks in BED format" + type: array + items: + type: object + properties: + smooth_bw: + path: "aligned_{genome}/{sample_name}_smooth.bw" + type: string + description: "A smooth bigwig file" + aligned_bam: + path: "aligned_{genome}/{sample_name}_sort.bam" + type: string + description: "A sorted, aligned BAM file" + peaks_bed: + path: "peak_calling_{genome}/{sample_name}_peaks.bed" + type: string + description: "Peaks in BED format" status: type: object properties: diff --git a/tests/data/sample_output_schema__without_project_with_samples_without_status.yaml b/tests/data/sample_output_schema__without_project_with_samples_without_status.yaml index 501f1bb1..f329ebcc 100644 --- a/tests/data/sample_output_schema__without_project_with_samples_without_status.yaml +++ b/tests/data/sample_output_schema__without_project_with_samples_without_status.yaml @@ -4,17 +4,19 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - smooth_bw: - path: "aligned_{genome}/{sample_name}_smooth.bw" - type: string - description: "A smooth bigwig file" - aligned_bam: - path: "aligned_{genome}/{sample_name}_sort.bam" - type: string - description: "A sorted, aligned BAM file" - peaks_bed: - path: "peak_calling_{genome}/{sample_name}_peaks.bed" - type: string - description: "Peaks in BED format" + type: array + items: + type: object + properties: + smooth_bw: + path: "aligned_{genome}/{sample_name}_smooth.bw" + type: string + description: "A smooth bigwig file" + aligned_bam: + path: "aligned_{genome}/{sample_name}_sort.bam" + type: string + description: "A sorted, aligned BAM file" + peaks_bed: + path: "peak_calling_{genome}/{sample_name}_peaks.bed" + type: string + description: "Peaks in BED format" diff --git a/tests/data/sample_output_schema_highlight.yaml b/tests/data/sample_output_schema_highlight.yaml index 7d5dbc16..06acfa37 100644 --- a/tests/data/sample_output_schema_highlight.yaml +++ b/tests/data/sample_output_schema_highlight.yaml @@ -4,49 +4,51 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - number_of_things: - type: integer - description: "Number of things" - percentage_of_things: - type: number - description: "Percentage of things" - name_of_something: - type: string - description: "Name of something" - switch_value: - type: boolean - description: "Is the switch on or off" - collection_of_things: - type: array - description: "This store collection of values" - output_object: - type: object - description: "Object output" - output_file: - $ref: "#/$defs/file" - description: "This a path to the output file" - output_image: - $ref: "#/$defs/image" - highlight: false - description: "This a path to the output image" - log: - $ref: "#/$defs/file" - highlight: true - description: "The log file of the pipeline run" - profile: - $ref: "#/$defs/file" - highlight: true - description: "The profile of the pipeline run" - commands: - $ref: "#/$defs/file" - highlight: true - description: "The file with shell commands executed by this pipeline" - version: - type: string - highlight: true - description: "Pipeline version" + type: array + items: + type: object + properties: + number_of_things: + type: integer + description: "Number of things" + percentage_of_things: + type: number + description: "Percentage of things" + name_of_something: + type: string + description: "Name of something" + switch_value: + type: boolean + description: "Is the switch on or off" + collection_of_things: + type: array + description: "This store collection of values" + output_object: + type: object + description: "Object output" + output_file: + $ref: "#/$defs/file" + description: "This a path to the output file" + output_image: + $ref: "#/$defs/image" + highlight: false + description: "This a path to the output image" + log: + $ref: "#/$defs/file" + highlight: true + description: "The log file of the pipeline run" + profile: + $ref: "#/$defs/file" + highlight: true + description: "The profile of the pipeline run" + commands: + $ref: "#/$defs/file" + highlight: true + description: "The file with shell commands executed by this pipeline" + version: + type: string + highlight: true + description: "Pipeline version" $defs: image: type: object diff --git a/tests/data/sample_output_schema_recursive.yaml b/tests/data/sample_output_schema_recursive.yaml index 1e315a88..ee916039 100644 --- a/tests/data/sample_output_schema_recursive.yaml +++ b/tests/data/sample_output_schema_recursive.yaml @@ -4,59 +4,61 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - number_of_things: - type: integer - description: "Number of things" - percentage_of_things: - type: number - description: "Percentage of things" - name_of_something: - type: string - description: "Name of something" - switch_value: - type: boolean - description: "Is the switch on or off" - md5sum: - type: string - description: "MD5SUM of an object" - highlight: true - collection_of_images: - description: "This store collection of values or objects" - type: array - items: - properties: - prop1: - description: "This is an example file" - $ref: "#/$defs/file" - output_file_in_object: - type: object - properties: - prop1: - description: "This is an example file" - $ref: "#/$defs/file" - prop2: - description: "This is an example image" - $ref: "#/$defs/image" - description: "Object output" - output_file_in_object_nested: - type: object - description: First Level - properties: - prop1: - type: object - description: Second Level + type: array + items: + type: object + properties: + number_of_things: + type: integer + description: "Number of things" + percentage_of_things: + type: number + description: "Percentage of things" + name_of_something: + type: string + description: "Name of something" + switch_value: + type: boolean + description: "Is the switch on or off" + md5sum: + type: string + description: "MD5SUM of an object" + highlight: true + collection_of_images: + description: "This store collection of values or objects" + type: array + items: properties: - prop2: - type: integer - description: Third Level - output_file: - $ref: "#/$defs/file" - description: "This a path to the output file" - output_image: - $ref: "#/$defs/image" - description: "This a path to the output image" + prop1: + description: "This is an example file" + $ref: "#/$defs/file" + output_file_in_object: + type: object + properties: + prop1: + description: "This is an example file" + $ref: "#/$defs/file" + prop2: + description: "This is an example image" + $ref: "#/$defs/image" + description: "Object output" + output_file_in_object_nested: + type: object + description: First Level + properties: + prop1: + type: object + description: Second Level + properties: + prop2: + type: integer + description: Third Level + output_file: + $ref: "#/$defs/file" + description: "This a path to the output file" + output_image: + $ref: "#/$defs/image" + description: "This a path to the output image" $defs: image: type: object diff --git a/tests/data/sample_output_schema_sqlite.yaml b/tests/data/sample_output_schema_sqlite.yaml index d3687b72..5cd14543 100644 --- a/tests/data/sample_output_schema_sqlite.yaml +++ b/tests/data/sample_output_schema_sqlite.yaml @@ -4,11 +4,13 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - number_of_things: - type: integer - description: "Number of things" - percentage_of_things: - type: number - description: "Percentage of things" \ No newline at end of file + type: array + items: + type: object + properties: + number_of_things: + type: integer + description: "Number of things" + percentage_of_things: + type: number + description: "Percentage of things" \ No newline at end of file diff --git a/tests/data/sample_output_schema_with_index.yaml b/tests/data/sample_output_schema_with_index.yaml index 6e48de7e..6b25a494 100644 --- a/tests/data/sample_output_schema_with_index.yaml +++ b/tests/data/sample_output_schema_with_index.yaml @@ -4,61 +4,63 @@ type: object properties: pipeline_name: "default_pipeline_name" samples: - type: object - properties: - number_of_things: - type: integer - description: "Number of things" - percentage_of_things: - type: number - description: "Percentage of things" - name_of_something: - type: string - description: "Name of something" - switch_value: - type: boolean - description: "Is the switch on or off" - md5sum: - type: string - description: "MD5SUM of an object" - highlight: true - index: True - collection_of_images: - description: "This store collection of values or objects" - type: array - items: - properties: - prop1: - description: "This is an example file" - $ref: "#/$defs/file" - output_file_in_object: - type: object - index: True - properties: - prop1: - description: "This is an example file" - $ref: "#/$defs/file" - prop2: - description: "This is an example image" - $ref: "#/$defs/image" - description: "Object output" - output_file_in_object_nested: - type: object - description: First Level - properties: - prop1: - type: object - description: Second Level + type: array + items: + type: object + properties: + number_of_things: + type: integer + description: "Number of things" + percentage_of_things: + type: number + description: "Percentage of things" + name_of_something: + type: string + description: "Name of something" + switch_value: + type: boolean + description: "Is the switch on or off" + md5sum: + type: string + description: "MD5SUM of an object" + highlight: true + index: True + collection_of_images: + description: "This store collection of values or objects" + type: array + items: properties: - prop2: - type: integer - description: Third Level - output_file: - $ref: "#/$defs/file" - description: "This a path to the output file" - output_image: - $ref: "#/$defs/image" - description: "This a path to the output image" + prop1: + description: "This is an example file" + $ref: "#/$defs/file" + output_file_in_object: + type: object + index: True + properties: + prop1: + description: "This is an example file" + $ref: "#/$defs/file" + prop2: + description: "This is an example image" + $ref: "#/$defs/image" + description: "Object output" + output_file_in_object_nested: + type: object + description: First Level + properties: + prop1: + type: object + description: Second Level + properties: + prop2: + type: integer + description: Third Level + output_file: + $ref: "#/$defs/file" + description: "This a path to the output file" + output_image: + $ref: "#/$defs/image" + description: "This a path to the output image" $defs: image: type: object