-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from fact-project/submit_runlist
Submit runlist
- Loading branch information
Showing
4 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import click | ||
import pandas as pd | ||
|
||
from ..automatic_processing.database_utils import insert_new_jobs | ||
from ..utils import load_config | ||
from datetime import date | ||
|
||
from ..automatic_processing.database import ( | ||
database, | ||
RawDataFile, | ||
Jar, | ||
XML, | ||
Queue, | ||
Job, | ||
) | ||
|
||
|
||
@click.command() | ||
@click.argument('runlist') | ||
@click.argument('jar') | ||
@click.argument('xml') | ||
@click.option( | ||
'-p', '--priority', default=5, type=int, | ||
help='Priority of the jobs, lower value means more important' | ||
) | ||
@click.option( | ||
'-q', '--queue', default='fact_short', | ||
help='Name of the queue to use' | ||
) | ||
@click.option('--config', '-c', help='Path to the yaml config file') | ||
def main(runlist, jar, xml, priority, queue, config): | ||
''' | ||
Submit automatic processing jobs for a given runlist | ||
Arguments | ||
RUNLIST: csv file with columns `night, run_id` | ||
JAR: version of the fact-tools jar | ||
XML: Name of the xml file to use | ||
Jar and XML must be uploaded to the processing db using erna_upload | ||
''' | ||
config = load_config(config) | ||
|
||
database.init(**config['processing_database']) | ||
|
||
jar = Jar.select(Jar.id, Jar.version).where(Jar.version == jar).get() | ||
xml = XML.get(name=xml, jar=jar) | ||
queue = Queue.get(name=queue) | ||
|
||
runs = pd.read_csv(runlist) | ||
runs['year'] = runs['night'] // 10000 | ||
runs['month'] = ((runs['night'] % 10000) // 100) | ||
runs['day'] = (runs['night'] % 100) | ||
|
||
files = [ | ||
RawDataFile.get(night=date(row.year, row.month, row.day), run_id=row.run_id) | ||
for row in runs.itertuples() | ||
] | ||
|
||
insert_new_jobs(files, xml=xml, jar=jar, queue=queue) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters