|
11 | 11 | from tiled.utils import path_from_uri |
12 | 12 |
|
13 | 13 |
|
14 | | -BEAMLINE_OR_ENDSTATION = "arpes" |
15 | | - |
16 | 14 | @task(retries=2, retry_delay_seconds=10) |
17 | | -def export_metadata_task(uid, beamline_acronym=BEAMLINE_OR_ENDSTATION): |
| 15 | +def export_metadata_task(run_client): |
18 | 16 | logger = get_run_logger() |
19 | | - |
20 | | - api_key = Secret.load(f"tiled-{beamline_acronym}-api-key", _sync=True).get() |
21 | | - tiled_client = from_profile("nsls2", api_key=api_key) |
22 | | - run_client = tiled_client[beamline_acronym]["migration"][uid] |
23 | | - logger.info(f"Obtained a Tiled client for Bluesky Run with uid {uid}. Exporting metadata...") |
24 | | - |
25 | 17 | start_time = time.monotonic() |
26 | 18 |
|
27 | 19 | # Find the data file that needs to be augmented with metadata |
@@ -125,5 +117,16 @@ def export_metadata_task(uid, beamline_acronym=BEAMLINE_OR_ENDSTATION): |
125 | 117 |
|
126 | 118 |
|
127 | 119 | @flow(log_prints=True) |
128 | | -def metadata_export_flow(uid): |
129 | | - export_metadata_task(uid) |
| 120 | +def metadata_export_flow(uid, beamline_acronym="arpes"): |
| 121 | + logger = get_run_logger() |
| 122 | + |
| 123 | + api_key = Secret.load(f"tiled-{beamline_acronym}-api-key", _sync=True).get() |
| 124 | + tiled_client = from_profile("nsls2", api_key=api_key) |
| 125 | + run_client = tiled_client[beamline_acronym]["migration"][uid] |
| 126 | + logger.info(f"Obtained a Tiled client for Bluesky Run with uid {uid}. Exporting metadata...") |
| 127 | + |
| 128 | + if ('primary' in run_client) and ('mbs_image' in run_client['primary']): |
| 129 | + export_metadata_task(run_client) |
| 130 | + |
| 131 | + else: |
| 132 | + logger.warning(f"No 'primary/mbs_image' data found for run {uid}. Skipping metadata export.") |
0 commit comments