Skip to content

Commit

Permalink
Add a helper script to submit a single experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Oct 18, 2023
1 parent da20769 commit e30585a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
41 changes: 41 additions & 0 deletions scripts/submit-experiment
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

import argparse
import sys
import os
from contextlib import contextmanager

import luigi

from rnaseq_pipeline.tasks import SubmitExperimentToGemma

@contextmanager
def umask(umask):
print(f'Setting umask to 0x{umask:03o}')
prev_umask = os.umask(umask)
try:
yield None
finally:
print(f'Restoring umask to 0x{prev_umask:03o}')
os.umask(prev_umask)

def parse_octal(s):
return int(s, 8)

def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('--experiment-id', required=True, help='Experiment ID to submit to Gemma')
parser.add_argument('--resubmit-batch-info', action='store_false', help='Only resubmit batch information')
parser.add_argument('--umask', type=parse_octal, default='002', help='Set a umask (defaults to 002 to make created files group-writable)')
parser.add_argument('--workers', type=int, default=100, help='Number of workers to use (defaults to 100)')
args = parser.parse_args(argv)
with umask(args.umask):
if args.batch_info:
task = SubmitExperimentBatchInfoToGemma(experiment_id=args.experiment_id, rerun=True)
else:
task = SubmitExperimentToGemma(experiment_id=args.experiment_id)
results = luigi.build([task], workers=args.workers, detailed_summary=True)
print(results.summary_text)

if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
10 changes: 5 additions & 5 deletions scripts/submit-experiments-from-gsheet
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def parse_octal(s):

def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('--spreadsheet-id')
parser.add_argument('--sheet-name')
parser.add_argument('--umask', type=parse_octal, default='002')
parser.add_argument('--workers', type=int, default=100)
parser.add_argument('--ignore-priority', action='store_true')
parser.add_argument('--spreadsheet-id', required=True, help='Spreadsheet ID')
parser.add_argument('--sheet-name', required=True, help='Sheet name')
parser.add_argument('--umask', type=parse_octal, default='002', help='Set a umask (defaults to 002 to make created files group-writable)')
parser.add_argument('--workers', type=int, default=100, help='Number of workers to use (defaults to 100)')
parser.add_argument('--ignore-priority', action='store_true', help='Ignore the priority column in the spreadsheet')
args = parser.parse_args(argv)
with umask(args.umask):
results = luigi.build([SubmitExperimentsFromGoogleSpreadsheetToGemma(args.spreadsheet_id, args.sheet_name, ignore_priority=args.ignore_priority)], workers=args.workers, detailed_summary=True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
extras_require={
'gsheet': ['google-api-python-client', 'google-auth-httplib2', 'google-auth-oauthlib', 'pyxdg'],
'webviewer': ['Flask', 'gunicorn']},
scripts=['scripts/luigi-wrapper', 'scripts/submit-experiments-from-gsheet'])
scripts=['scripts/luigi-wrapper', 'scripts/submit-experiments-from-gsheet', 'scripts/submit-experiment'])

0 comments on commit e30585a

Please sign in to comment.