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 authored and wguanicedew committed Apr 3, 2024
1 parent 8a6235f commit d9c3465
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 12 deletions.
36 changes: 34 additions & 2 deletions python/lsst/ctrl/bps/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,33 @@ 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 411 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L409 - L411 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 416 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L415-L416

Added lines #L415 - L416 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 419 in python/lsst/ctrl/bps/drivers.py

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L418 - L419 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)
kwargs["remote_build"] = remote_build
kwargs["config_file"] = config_file
wms_workflow = None

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

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/drivers.py#L429-L432

Added lines #L429 - L432 were not covered by tests
else:
_LOG.info("The workflow is sumitted to the local Data Facility.")

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 submission process")
with time_this(
log=_LOG,
Expand All @@ -416,7 +443,10 @@ 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 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:
wms_workflow_config = config

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("Starting submit stage")
with time_this(
Expand All @@ -428,7 +458,9 @@ def submit_driver(config_file, **kwargs):
mem_unit=DEFAULT_MEM_UNIT,
mem_fmt=DEFAULT_MEM_FMT,
):
submit(wms_workflow_config, wms_workflow)
workflow = submit(wms_workflow_config, wms_workflow, **kwargs)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L461 was not covered by tests
if not wms_workflow:
wms_workflow = workflow

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L463 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
26 changes: 16 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, **kwargs):
"""Convert generic workflow to a workflow for a particular WMS.
Parameters
Expand All @@ -60,18 +60,24 @@ 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"]
)
remote_build = kwargs["remote_build"] if "remote_build" in kwargs else None
kwargs["config"] = config

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#L63-L64

Added lines #L63 - L64 were not covered by tests

if not remote_build:
_, when_create = config.search(".executionButler.whenCreate")

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#L67

Added line #L67 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 70 in python/lsst/ctrl/bps/submit.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/ctrl/bps/submit.py#L69-L70

Added lines #L69 - L70 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 74 in python/lsst/ctrl/bps/submit.py

View check run for this annotation

Codecov / codecov/patch

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

Added line #L74 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)
workflow = wms_service.submit(wms_workflow, **kwargs)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L82 was not covered by tests
return workflow

0 comments on commit d9c3465

Please sign in to comment.