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

Independent function for starting the DM workflow after acquisition and nexus file writing is complete #104

Open
qzhang234 opened this issue Nov 4, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@qzhang234
Copy link
Contributor

We would like to have an independent function for starting the DM workflow after the acquisition is done and the nexus hdf metadata file is written.

We would prefer to have a plain python function independent from Bluesky RE (and potentially apstools, if possible) so that it is easier for beamline folks to develop, maintain and debug.

@qzhang234 qzhang234 added the enhancement New feature or request label Nov 4, 2024
@qzhang234
Copy link
Contributor Author

qzhang234 commented Nov 5, 2024

@banubot provided a template for starting DM from the DM's python environment. Looks like the only input variables needed are in argsDict and there are only 3 of them. Would Bluesky be able to communicate these variables with Hannah's DM environment, either via text files or String Registers? By the way all the fields Hannah needs are currently being written in the StrReg in my acquisition code

# This script is an example of how to start 
# the XPCS boost corr workflow using the DM python API
# Usage: source /home/dm/etc/dm.setup.sh; python dm_api_example.py

from dm.proc_web_service.api.procApiFactory import ProcApiFactory


# Get the DM workflow API object
dmWorkflowApi = ProcApiFactory.getWorkflowProcApi()

# Define the workflow arguments in a dict
argsDict = {
    "filePath": "H001_005_test_Feb_7-01000.h5",
    "qmap": "eiger4M_qmap_d36_s360.h5",
    "experimentName": "zhang202402",
}

workflowOwner = "8idiuser"
workflowName = "xpcs8-02-gladier-boost"
# Start the processing job
response = dmWorkflowApi.startProcessingJob(workflowOwner, workflowName, argsDict)
# Print the job ID
print(response.get('id'))

# To do the same thing using CLI instead of python, run:
# dm-start-processing-job --workflow-name xpcs8-02-gladier-boost filePath:H001_005_test_Feb_7-01000.h5 qmap:eiger4M_qmap_d36_s360.h5 experimentName:zhang202402

@prjemian
Copy link
Contributor

prjemian commented Nov 6, 2024

Bluesky has a different set of Python package requirements than APS Data Management. The bluesky instrument package has provided an adaptation that provides access to the full set of Python software provided by APS DM. The adaptation is enabled by defining all the environment variables required by DM:

def dm_source_environ():

Various DM APIs are already provided:

~dm_api_cat
~dm_api_daq
~dm_api_dataset_cat
~dm_api_ds
~dm_api_file
~dm_api_file_cat
~dm_api_proc

For example, dm_api_cat:

def dm_api_cat():
"""Return the APS Data Management Catalog API object."""
from dm import CatApiFactory
dm_source_environ()
return CatApiFactory.getRunCatApi()

@prjemian
Copy link
Contributor

prjemian commented Nov 6, 2024

Since dm_source_environ() is run when starting a bluesky session, @banubot's example above can be run from a bluesky session.

@prjemian
Copy link
Contributor

prjemian commented Nov 6, 2024

@qzhang234 Is there any additional work to be done to resolve this issue?

@qzhang234
Copy link
Contributor Author

qzhang234 commented Nov 6, 2024 via email

@prjemian
Copy link
Contributor

A low-level plan (bluesky plan stub that wraps DMs startProcessingJob() function) is described in the bs_model_instrument. This is part of PR BCDA-APS/bs_model_instrument#20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants