Skip to content

Commit

Permalink
Merge pull request #3 from lcdesilva/prefect2-test
Browse files Browse the repository at this point in the history
Prefect2 test
  • Loading branch information
lcdesilva authored Apr 14, 2023
2 parents 6cd0507 + 5775985 commit 8ab4e5d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .prefectignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# prefect artifacts
.prefectignore

# python artifacts
__pycache__/
*.py[cod]
*$py.class
*.egg-info/
*.egg

# Type checking artifacts
.mypy_cache/
.dmypy.json
dmypy.json
.pyre/

# IPython
profile_default/
ipython_config.py
*.ipynb_checkpoints/*

# Environments
.python-version
.env
.venv
env/
venv/

# MacOS
.DS_Store

# Dask
dask-worker-space/

# Editors
.idea/
.vscode/

# VCS
.git/
.hg/
25 changes: 25 additions & 0 deletions data_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from prefect import task, flow, get_run_logger
import time as ttime
from tiled.client import from_profile

tiled_client = from_profile("nsls2", username=None)

@task(retries=2, retry_delay_seconds=10)
def read_all_streams(beamline_acronym, uid):
logger = get_run_logger()
run = tiled_client[beamline_acronym]["raw"][uid]
logger.info(f"Validating uid {run.start['uid']}")
start_time = ttime.monotonic()
for stream in run:
logger.info(f"{stream}:")
stream_start_time = ttime.monotonic()
stream_data = run[stream].read()
stream_elapsed_time = ttime.monotonic() - stream_start_time
logger.info(f"{stream} elapsed_time = {stream_elapsed_time}")
logger.info(f"{stream} nbytes = {stream_data.nbytes:_}")
elapsed_time = ttime.monotonic() - start_time
logger.info(f"{elapsed_time = }")

@flow
def general_data_validation(beamline_acronym, uid):
read_all_streams(beamline_acronym, uid)

0 comments on commit 8ab4e5d

Please sign in to comment.