Skip to content

Commit

Permalink
create a build task for remote submission
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyu committed Oct 7, 2023
1 parent 1510ddf commit 5c70534
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 12 deletions.
32 changes: 30 additions & 2 deletions python/lsst/ctrl/bps/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,30 @@ def submit_driver(config_file, **kwargs):
"not accurately reflect actual memory usage by the bps process."
)

remote_build = {}
config = BpsConfig(config_file, BPS_SEARCH_ORDER)
_, remote_build = config.search("remoteBuild", opt={"default": {}})

Check warning on line 401 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L399-L401

Added lines #L399 - L401 were not covered by tests
if remote_build:
if config["wmsServiceClass"] == "lsst.ctrl.bps.panda.PanDAService":
if not remote_build.search("enabled", opt={"default": False})[1]:
remote_build = {}
_LOG.info("The workflow is sumitted to the local Data Facility.")

Check warning on line 406 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L405-L406

Added lines #L405 - L406 were not covered by tests
else:
_LOG.info("Remote submission is enabled. The workflow is sumitted to a remote Data Facility.")
_LOG.info("Initializing execution environment")

Check warning on line 409 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L408-L409

Added lines #L408 - L409 were not covered by tests
with time_this(
log=_LOG,
level=logging.INFO,
prefix=None,
msg="Initializing execution environment completed",
mem_usage=True,
mem_unit=DEFAULT_MEM_UNIT,
mem_fmt=DEFAULT_MEM_FMT,
):
config = _init_submission_driver(config_file, **kwargs)

Check warning on line 419 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L419

Added line #L419 was not covered by tests
else:
_LOG.info("The workflow is sumitted to the local Data Facility.")

Check warning on line 421 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L421

Added line #L421 was not covered by tests

_LOG.info("Starting submission process")
with time_this(
log=_LOG,
Expand All @@ -406,7 +430,8 @@ def submit_driver(config_file, **kwargs):
mem_unit=DEFAULT_MEM_UNIT,
mem_fmt=DEFAULT_MEM_FMT,
):
wms_workflow_config, wms_workflow = prepare_driver(config_file, **kwargs)
if not remote_build:
wms_workflow_config, wms_workflow = prepare_driver(config_file, **kwargs)

Check warning on line 434 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L434

Added line #L434 was not covered by tests

_LOG.info("Starting submit stage")
with time_this(
Expand All @@ -418,7 +443,10 @@ def submit_driver(config_file, **kwargs):
mem_unit=DEFAULT_MEM_UNIT,
mem_fmt=DEFAULT_MEM_FMT,
):
submit(wms_workflow_config, wms_workflow)
if remote_build:
wms_workflow = submit(config, None, remote_build=remote_build, config_file=config_file)

Check warning on line 447 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L447

Added line #L447 was not covered by tests
else:
submit(wms_workflow_config, wms_workflow)

Check warning on line 449 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L449

Added line #L449 was not covered by tests
_LOG.info("Run '%s' submitted for execution with id '%s'", wms_workflow.name, wms_workflow.run_id)
if _LOG.isEnabledFor(logging.INFO):
_LOG.info(
Expand Down
28 changes: 18 additions & 10 deletions python/lsst/ctrl/bps/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@


@timeMethod(logger=_LOG, logLevel=VERBOSE)
def submit(config, wms_workflow, wms_service=None):
def submit(config, wms_workflow, wms_service=None, remote_build=None, config_file=None):
"""Convert generic workflow to a workflow for a particular WMS.
Parameters
Expand All @@ -60,18 +60,26 @@ def submit(config, wms_workflow, wms_service=None):
wms_service_class = doImport(config["wmsServiceClass"])
wms_service = wms_service_class(config)

_, when_create = config.search(".executionButler.whenCreate")
if when_create.upper() == "SUBMIT":
_, execution_butler_dir = config.search(".bps_defined.executionButlerDir")
_LOG.info("Creating execution butler in '%s'", execution_butler_dir)
with time_this(log=_LOG, level=logging.INFO, prefix=None, msg="Completed creating execution butler"):
_create_execution_butler(
config, config["runQgraphFile"], execution_butler_dir, config["submitPath"]
)
if not remote_build:
_, when_create = config.search(".executionButler.whenCreate")

Check warning on line 64 in python/lsst/ctrl/bps/submit.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/submit.py#L64

Added line #L64 was not covered by tests
if when_create.upper() == "SUBMIT":
_, execution_butler_dir = config.search(".bps_defined.executionButlerDir")
_LOG.info("Creating execution butler in '%s'", execution_butler_dir)

Check warning on line 67 in python/lsst/ctrl/bps/submit.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/submit.py#L66-L67

Added lines #L66 - L67 were not covered by tests
with time_this(
log=_LOG, level=logging.INFO, prefix=None, msg="Completed creating execution butler"
):
_create_execution_butler(

Check warning on line 71 in python/lsst/ctrl/bps/submit.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/submit.py#L71

Added line #L71 was not covered by tests
config, config["runQgraphFile"], execution_butler_dir, config["submitPath"]
)

_LOG.info("Submitting run to a workflow management system for execution")
with time_this(
log=_LOG, level=logging.INFO, prefix=None, msg="Completed submitting to a workflow management system"
):
workflow = wms_service.submit(wms_workflow)
if remote_build:
workflow = wms_service.submit(

Check warning on line 80 in python/lsst/ctrl/bps/submit.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/submit.py#L80

Added line #L80 was not covered by tests
wms_workflow, config=config, remote_build=remote_build, config_file=config_file
)
else:
workflow = wms_service.submit(wms_workflow)

Check warning on line 84 in python/lsst/ctrl/bps/submit.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/submit.py#L84

Added line #L84 was not covered by tests
return workflow

0 comments on commit 5c70534

Please sign in to comment.