-
Notifications
You must be signed in to change notification settings - Fork 2
adding proc card displays #31
base: master
Are you sure you want to change the base?
Changes from all commits
9421845
c69fbff
04ff1b8
843b67e
c69a683
442d00c
b1957c7
ceecf10
c70610a
028bc18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ class MadgraphGridpack(Gridpack): | |
|
|
||
| def prepare_default_card(self): | ||
| """ | ||
| Copy default cards to local directory | ||
| Copy default cards to local directory : proc_card.dat and madspin_card.dat | ||
| """ | ||
| cards_path = self.get_cards_path() | ||
| job_files_path = self.get_job_files_path() | ||
|
|
@@ -17,6 +17,26 @@ def prepare_default_card(self): | |
| if glob.glob(f'{cards_path}/*_cuts.f'): | ||
| os.system(f'cp {cards_path}/*_cuts.f {job_files_path}') | ||
|
|
||
|
|
||
| def get_proc_card(self): | ||
| """ | ||
| Read proc card | ||
| Glue madspin card if it exists | ||
| """ | ||
| if glob.glob(f'{cards_path}/*_proc_card.dat'): | ||
| with open(f'{cards_path}/*_proc_card.dat') as input_file: | ||
| proc_card = input_file.read() | ||
| else: | ||
| raise Exception(f'Could not find {cards_path} as process card') | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. proc card should always exist |
||
|
|
||
| if glob.glob(f'{cards_path}/*_madspin_card.dat'): | ||
| with open(f'{cards_path}/*_madpsin_card.dat') as input_file: | ||
| proc_card += '\n\n\n\n\n\n#### madspin_card.dat\n' | ||
| proc_card += input_file.read() | ||
|
|
||
| return proc_card | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. madspin card depends on situation, add #### banner to split proc_card and madspin_card.dat parts |
||
|
|
||
| def get_run_card(self): | ||
| """ | ||
| Get cards from "Template" directory and customize them | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -258,21 +258,19 @@ def get_gridpacks(): | |
| return output_text([gridpacks, count]) | ||
|
|
||
|
|
||
| @app.route('/api/get_fragment/<string:gridpack_id>') | ||
| def get_fragment(gridpack_id): | ||
| @app.route('/api/get_proc_card/<string:gridpack_id>') | ||
| def get_proc_card(gridpack_id): | ||
| """ | ||
| API to get gridpack's fragment | ||
| API to get gridpack's proc card | ||
| """ | ||
| database = Database() | ||
| gridpack_json = database.get_gridpack(gridpack_id) | ||
| if not gridpack_json: | ||
| return output_text({'message': 'Gridpack not found'}, code=404) | ||
|
|
||
| gridpack = Gridpack.make(gridpack_json) | ||
| fragment_builder = FragmentBuilder() | ||
| fragment = fragment_builder.build_fragment(gridpack) | ||
|
|
||
| return output_text(fragment, headers={'Content-Type': 'text/plain'}) | ||
| content = gridpack.get_proc_card() | ||
| return output_text(content, headers={'Content-Type': 'text/plain'}) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are |
||
|
|
||
|
|
||
| @app.route('/api/get_run_card/<string:gridpack_id>') | ||
|
|
@@ -305,6 +303,23 @@ def get_customize_card(gridpack_id): | |
| return output_text(content, headers={'Content-Type': 'text/plain'}) | ||
|
|
||
|
|
||
| @app.route('/api/get_fragment/<string:gridpack_id>') | ||
| def get_fragment(gridpack_id): | ||
| """ | ||
| API to get gridpack's fragment | ||
| """ | ||
| database = Database() | ||
| gridpack_json = database.get_gridpack(gridpack_id) | ||
| if not gridpack_json: | ||
| return output_text({'message': 'Gridpack not found'}, code=404) | ||
|
|
||
| gridpack = Gridpack.make(gridpack_json) | ||
| fragment_builder = FragmentBuilder() | ||
| fragment = fragment_builder.build_fragment(gridpack) | ||
|
|
||
| return output_text(fragment, headers={'Content-Type': 'text/plain'}) | ||
|
|
||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this i didn't really touch other than copy pasting to this other lines |
||
| def user_info_dict(): | ||
| """ | ||
| Get user name, login, email and authorized flag from request headers | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,7 @@ class PowhegGridpack(Gridpack): | |
|
|
||
| def get_run_card(self): | ||
| """ | ||
| Get cards from "Template" directory and customize them | ||
| Get cards from "ModelParams" directory and customize them | ||
| Glue them together | ||
| Get cards from "Template" directory and customize them (run card) | ||
| """ | ||
| dataset_dict = self.get_dataset_dict() | ||
| campaign_dict = self.get_campaign_dict() | ||
|
|
@@ -24,6 +22,14 @@ def get_run_card(self): | |
| dataset_dict.get('template_user', []), | ||
| template_vars) | ||
|
|
||
| return run_card | ||
|
|
||
| def get_customize_card(self) | ||
| """ | ||
| Get cards from "ModelParams" directory and customize them (customize card) | ||
| """ | ||
| dataset_dict = self.get_dataset_dict() | ||
| campaign_dict = self.get_campaign_dict() | ||
| model_params_path = self.get_model_params_path() | ||
| model_params_name = dataset_dict['model_params'] | ||
| model_params_vars = dataset_dict.get('model_params_vars', []) | ||
|
|
@@ -33,21 +39,21 @@ def get_run_card(self): | |
| dataset_dict.get('model_params_user', []), | ||
| model_params_vars) | ||
|
|
||
| return run_card + '\n' + customize_card | ||
| return customize_card | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. run card and customize card are split into two now (for better api displays) |
||
|
|
||
| def prepare_run_card(self): | ||
| def prepare_input_card(self): | ||
| """ | ||
| Get run card and write it to job files dir | ||
| Get run card and customize card, glue them together into input card and write it to job files dir | ||
| """ | ||
| job_files_path = self.get_job_files_path() | ||
| output_file_name = os.path.join(job_files_path, 'powheg.input') | ||
| run_card = self.get_run_card() | ||
| self.logger.debug('Writing customized run card %s', output_file_name) | ||
| self.logger.debug(run_card) | ||
| input_card = self.get_run_card() + '\n\n\n\n' + self.get_customize_card() | ||
| self.logger.debug('Writing customized input card %s', output_file_name) | ||
| self.logger.debug(input_card) | ||
| with open(output_file_name, 'w') as output_file: | ||
| output_file.write(run_card) | ||
| output_file.write(input_card) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename |
||
|
|
||
| def get_customize_card(self): | ||
| def get_proc_card(self): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simply rename |
||
| """ | ||
| Create card with just the process name for proper Powheg gridpack | ||
| production | ||
|
|
@@ -56,25 +62,25 @@ def get_customize_card(self): | |
| template_name = dataset_dict['template'] | ||
| return template_name.split('.', 1)[0] | ||
|
|
||
| def prepare_customize_card(self): | ||
| def prepare_proc_card(self): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. simply renamed |
||
| """ | ||
| Get customize card and write it to job files dir | ||
| Get proc card and write it to job files dir | ||
| """ | ||
| job_files_path = self.get_job_files_path() | ||
| output_file_name = os.path.join(job_files_path, 'process.dat') | ||
| customize_card = self.get_customize_card() | ||
| self.logger.debug('Writing customized card %s', output_file_name) | ||
| self.logger.debug(customize_card) | ||
| proc_card = self.get_proc_card() | ||
| self.logger.debug('Writing proc card %s', output_file_name) | ||
| self.logger.debug(proc_card) | ||
| with open(output_file_name, 'w') as output_file: | ||
| output_file.write(customize_card) | ||
| output_file.write(proc_card) | ||
|
|
||
| def prepare_job_archive(self): | ||
| """ | ||
| Make an archive with all necessary job files | ||
| """ | ||
| job_files_path = self.get_job_files_path() | ||
| pathlib.Path(job_files_path).mkdir(parents=True, exist_ok=True) | ||
| self.prepare_run_card() | ||
| self.prepare_customize_card() | ||
| self.prepare_input_card() | ||
| self.prepare_proc_card() | ||
| local_dir = self.local_dir() | ||
| os.system(f'tar -czvf {local_dir}/input_files.tar.gz -C {local_dir} input_files') | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't do anything in
madgraph_gridpack.py. It's only formain.py:get_proc_cardweb api purposes