Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute cmsRun to validate driver parameters #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/controller/relval_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def get_editing_info(self, obj):
editing_info["workflow_id"] = False
editing_info["workflow_name"] = is_new
editing_info["steps"] = is_new
editing_info["execute_steps"] = True

return editing_info

Expand Down
21 changes: 21 additions & 0 deletions core/model/relval.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class RelVal(ModelBase):
'workflow_name': '',
# ReqMgr2 names
'workflows': [],
# Execute `cmsRun` when preparing the
# configuration file
'execute_steps': False,
}

lambda_checks = {
Expand Down Expand Up @@ -323,3 +326,21 @@ def get_campaign(self):
return f'{cmssw_release}__{batch_name}-{campaign_timestamp}'

return f'{cmssw_release}__{batch_name}'

def execute_steps_for_configuration(self) -> bool:
"""
Determine if the `cmsRun` command should be executed
when generating the Python configuration.
"""
execute_steps = None
try:
execute_steps = self.get('execute_steps')
except Exception as e:
self.logger.error("Unable to retrieve the execute_steps attribute: %s", e)

self.logger.debug('Execute steps is set: %s', execute_steps)
# If the document does not set it
if not isinstance(execute_steps, bool):
return False

return execute_steps
8 changes: 6 additions & 2 deletions core/model/relval_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,12 @@ def get_command(self, custom_fragment=None, for_submission=False):
if custom_fragment:
arguments_dict['fragment_name'] = custom_fragment

# No execution
arguments_dict['no_exec'] = True
# Enable the execution of `cmsRun` for a quick
# validation
execute_cmsrun = self.parent().execute_steps_for_configuration()
if not execute_cmsrun:
arguments_dict['no_exec'] = True

# Handle input/output file names
arguments_dict['fileout'] = f'"file:step{index + 1}.root"'
arguments_dict['python_filename'] = f'{self.get_config_file_name()}.py'
Expand Down
33 changes: 33 additions & 0 deletions scripts/add_execute_steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
This script sets the new attribute
`execute_steps` on every `RelVal` object that
does not include it already.
"""
import sys
import os.path
import os
# pylint: disable-next=wrong-import-position
sys.path.append(os.path.abspath(os.path.pardir))
from core_lib.database.database import Database

# Configure the database client
mongo_db_username = os.getenv("MONGO_DB_USERNAME", "")
mongo_db_password = os.getenv("MONGO_DB_PASSWORD", "")
mongo_db_host = os.getenv("MONGO_DB_HOST", "")
mongo_db_port = int(os.getenv("MONGO_DB_PORT", "27017"))
Database.set_host_port(host=mongo_db_host, port=mongo_db_port)
Database.set_credentials(username=mongo_db_username, password=mongo_db_password)
Database.set_database_name('relval')

database = Database('relvals')
total_entries = database.get_count()
print('Total entries: %s' % (total_entries))

for index, item in enumerate(database.query(limit=total_entries)):
print('Processing entry %s/%s %s' % (index + 1, total_entries, item.get('prepid', '<no-id>')))
execute_steps = item.get('execute_steps')
if execute_steps is None:
item['execute_steps'] = False
database.save(item)

print('Done')
1 change: 1 addition & 0 deletions vue_frontend/src/components/RelVals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export default {
{'dbName': 'status', 'displayName': 'Status', 'visible': 1, 'sortable': true},
{'dbName': 'batch_name', 'displayName': 'Batch Name', 'visible': 1, 'sortable': true},
{'dbName': 'cmssw_release', 'displayName': 'CMSSW Release', 'visible': 1, 'sortable': true},
{'dbName': 'execute_steps', 'displayName': 'Execute cmsRun', 'visible': 1},
{'dbName': 'cpu_cores', 'displayName': 'CPU Cores', 'visible': 1, 'sortable': true},
{'dbName': 'matrix', 'displayName': 'Matrix', 'visible': 1, 'sortable': true},
{'dbName': 'memory', 'displayName': 'Memory', 'visible': 1, 'sortable': true},
Expand Down
11 changes: 11 additions & 0 deletions vue_frontend/src/components/RelValsEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,17 @@
<v-btn small class="mr-1 mb-1 mt-1" color="primary" @click="addStep()">Add step {{listLength(editableObject.steps) + 1}}</v-btn>
</td>
</tr>
<tr>
<td>Execute cmsRun for steps</td>
<td>
<input
type="checkbox"
title="Execute cmsRun for every step with a few events to cross-check the configuration"
v-model="editableObject.execute_steps"
:disabled="!editingInfo.execute_steps"
/>
</td>
</tr>
<tr>
<td>Time per event</td>
<td><input type="number" v-model="editableObject.time_per_event" :disabled="!editingInfo.time_per_event">s</td>
Expand Down
Loading