Skip to content

Commit

Permalink
feat: omics launcher (#18)
Browse files Browse the repository at this point in the history
* INPUT_METADATA

* rename events

* bump memory size

* try parent

* save metadata successfully
  • Loading branch information
drernie authored Dec 12, 2023
1 parent b06b3b3 commit c014a9c
Show file tree
Hide file tree
Showing 22 changed files with 104 additions and 11,111 deletions.
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export class Constants {
READY2RUN_WORKFLOW_ID: '9500764',
MANIFEST_ROOT: 'fastq',
MANIFEST_SUFFIX: '.json',
INPUT_METADATA: 'input_metadata.json',
QUILT_METADATA: 'quilt_metadata.json',
FASTQ_SENTINEL: 'out/bqsr_report/NA12878.hg38.recal_data.csv',
MEMORY_SIZE: 8192,
TIMEOUT: '900',
};

Expand Down
23 changes: 15 additions & 8 deletions src/omics-quilt.fastq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,23 @@ export async function handler(event: any, context: any) {
return { message: 'Success' };
}

async function save_metadata(item: any, cc: Constants) {
const sentinel_file = cc.get('QUILT_METADATA)');
if (!sentinel_file) {
console.info('No QUILT_METADATA, skipping metadata save');
export async function save_metadata(id: string, item: any, cc: Constants) {
const location = cc.get('OUTPUT_S3_LOCATION');
if (!location) {
console.info('No OUTPUT_S3_LOCATION, skipping metadata save');
return;
}
console.info(`Writing input to ${sentinel_file}`);
await Constants.SaveObjectURI(sentinel_file, item);
const metadata_file = cc.get('INPUT_METADATA');
if (!metadata_file) {
console.info('No INPUT_METADATA, skipping metadata save');
return;
}
const uri = `${location}/${id}/out/${metadata_file}`;
console.info(`Writing input to ${uri}`);
await Constants.SaveObjectURI(uri, item);
}

async function run_workflow(
export async function run_workflow(
item: Record<string, string>,
uri: string,
cc: Constants,
Expand Down Expand Up @@ -111,7 +117,8 @@ async function run_workflow(
run: response,
workflow: options,
};
await save_metadata(run_metadata, cc);
const id = response.id!;
await save_metadata(id, run_metadata, cc);
}
} catch (e: any) {
console.error('Error : ' + e.toString());
Expand Down
4 changes: 3 additions & 1 deletion src/omics-quilt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class OmicsQuiltStack extends Stack {
return new NodejsFunction(this, name, {
runtime: Runtime.NODEJS_18_X,
role: this.lambdaRole,
timeout: Duration.seconds(this.cc.timeout()),
timeout: Duration.seconds(60),
retryAttempts: 1,
environment: this.makeLambdaEnv(env),
});
Expand All @@ -217,6 +217,7 @@ export class OmicsQuiltStack extends Stack {
runtime: Runtime.PYTHON_3_11,
role: this.lambdaRole,
timeout: Duration.seconds(this.cc.timeout()),
memorySize: this.cc.get('MEMORY_SIZE'),
retryAttempts: 1,
environment: this.makeLambdaEnv(env),
bundling: {
Expand All @@ -235,6 +236,7 @@ export class OmicsQuiltStack extends Stack {
OMICS_ROLE: this.omicsRole.roleArn,
OUTPUT_S3_LOCATION: output.join('/'),
SENTINEL_FILE: this.packager_sentinel,
INPUT_METADATA: this.cc.get('INPUT_METADATA'),
QUILT_METADATA: this.cc.get('QUILT_METADATA'),
WORKFLOW_ID: this.cc.get('READY2RUN_WORKFLOW_ID'),
TIMEOUT: this.cc.get('TIMEOUT'),
Expand Down
1 change: 1 addition & 0 deletions src/packager/packager/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Constants:
"TIMESTAMP_FILE": "quilt_timestamp.json",
"SOURCE_APP": "omics-quilt",
"QUILT_METADATA": "quilt_metadata.json",
"INPUT_METADATA": "input_metadata.json",
"QUILT_SUMMARIZE": "quilt_summarize.json",
"FASTQ_SENTINEL": "out/bqsr_report/NA12878.hg38.recal_data.csv",
}
Expand Down
6 changes: 5 additions & 1 deletion src/packager/packager/gsa_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GSAHandler:
@staticmethod
def ReportRoot(report_uri: str) -> Path:
report_path = Constants.ToPath(report_uri)
return report_path.parent # WAS: .parent.parent
return report_path.parent.parent

@staticmethod
def ParseURI(file_uri: str) -> KEYED:
Expand Down Expand Up @@ -142,6 +142,10 @@ def packageFolder(self, root: Path, opts: KEYED) -> KEYED:
meta: KEYED = json.loads(text)
else:
meta = {}
input_file = root / self.cc.get("INPUT_METADATA")
if input_file.exists():
text = input_file.read_text()
meta["input"] = json.loads(text)
meta["options"] = opts
meta["context"] = self.context

Expand Down
18 changes: 0 additions & 18 deletions src/packager/tests/outputs/8637245/out/bqsr_report/Arguments.csv

This file was deleted.

95 changes: 0 additions & 95 deletions src/packager/tests/outputs/8637245/out/bqsr_report/Quantized.csv

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions src/packager/tests/outputs/8637245/out/bqsr_report/RecalTable1.csv

This file was deleted.

Loading

0 comments on commit c014a9c

Please sign in to comment.