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

Uber 832 Flow Decider #32

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Changes from 1 commit
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
58 changes: 58 additions & 0 deletions orchestration/flows/bl832/decision_flow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from prefect import flow, task, get_run_logger
from prefect.blocks.system import JSON
from prefect.deployments.deployments import run_deployment


@task(name="setup_decision_settings")
def setup_decision_settings(alcf_recon: bool,
nersc_recon: bool,
nersc_move: bool) -> dict:
"""
This task is used to define the settings for the decision making process of the BL832 beamline.
"""
logger = get_run_logger()
logger.info(f"Setting up decision settings: alcf_recon={alcf_recon}, "
f"nersc_recon={nersc_recon}, nersc_move={nersc_move}")
settings = {
"process_new_832_ALCF_flow": alcf_recon,
"nersc_recon": nersc_recon,
"new_file_832": nersc_move
}
settings_json = JSON(value=settings)
settings_json.save(name="decision-settings", overwrite=True)
return settings


@task(name="run_specific_flow")
def run_specific_flow(flow_name: str) -> None:
"""
This task is used to run a specific flow.
"""
logger = get_run_logger()
logger.info(f"Running {flow_name}")
run_deployment(flow_name)


@flow(name="decision_flow")
def decision_flow():
"""
This flow is used to define the decision making process of the BL832 beamline.
"""
logger = get_run_logger()
logger.info("Starting decision flow")
decision_settings = JSON.load("decision-settings")
for flow_name, run_flow in decision_settings.value.items():
dylanmcreynolds marked this conversation as resolved.
Show resolved Hide resolved
print(f"{flow_name}")
print(f"{run_flow}")
if run_flow:
run_specific_flow(flow_name)
else:
logger.info(f"Skipping {flow_name}")


if __name__ == "__main__":
"""
This script is used to define the flow for the decision making process of the BL832 beamline.
"""
setup_decision_settings(alcf_recon=True, nersc_recon=False, nersc_move=True)
decision_flow()
Loading