Skip to content

Commit 7ca1a31

Browse files
committed
add cli command and readme
1 parent 356915b commit 7ca1a31

4 files changed

Lines changed: 67 additions & 2 deletions

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
11
# Workflows
22

33
Repository of workflows for the FXI beamline.
4+
5+
## Running the Exporter Locally
6+
7+
First, install dependencies:
8+
9+
```bash
10+
pixi install
11+
```
12+
13+
Then from the project directory:
14+
15+
```bash
16+
pixi run exporter <uid> [output_dir]
17+
```
18+
19+
For example:
20+
21+
```bash
22+
pixi run exporter 02b93a93-43cf-45ad-8fda-792c1373dcec /tmp/exports
23+
```
24+
25+
If `output_dir` is omitted, it defaults to `/tmp/exports`.
26+
27+
### Running from anywhere
28+
29+
Use the `-m` flag to specify the manifest path:
30+
31+
```bash
32+
pixi run -m /path/to/fxi-workflows/pixi.toml exporter <uid>
33+
```
34+
35+
Or add an alias to your shell config (`~/.zshrc` or `~/.bashrc`):
36+
37+
```bash
38+
alias exporter='pixi run -m /path/to/fxi-workflows/pixi.toml exporter'
39+
```
40+
41+
Then run from anywhere:
42+
43+
```bash
44+
exporter <uid>
45+
```

end_of_run_workflow.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,22 @@ def end_of_run_workflow_local(uid, output_dir="/tmp/exports"):
117117
logger.info(f"Export complete: uid={uid} scan_id={scan_id}")
118118

119119

120-
if __name__ == "__main__":
120+
def main():
121+
import os
121122
import sys
122123

124+
# Clear Prefect Cloud env vars so the flow runs locally.
125+
os.environ.pop("PREFECT_API_URL", None)
126+
os.environ.pop("PREFECT_API_KEY", None)
127+
123128
if len(sys.argv) < 2:
124-
print("Usage: python end_of_run_workflow.py <uid> [output_dir]")
129+
print("Usage: exporter <uid> [output_dir]")
125130
sys.exit(1)
126131

127132
uid = sys.argv[1]
128133
output_dir = sys.argv[2] if len(sys.argv) > 2 else "/tmp/exports"
129134
end_of_run_workflow_local(uid, output_dir=output_dir)
135+
136+
137+
if __name__ == "__main__":
138+
main()

pixi.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ channels = ["conda-forge"]
33
name = "prefect3 test"
44
platforms = ["linux-64", "osx-64"]
55

6+
[tasks]
7+
exporter = "python end_of_run_workflow.py"
8+
69
[dependencies]
710
prefect = "3.*"
811
python = "<3.14"

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "fxi-workflows"
7+
version = "0.1.0"
8+
9+
[project.scripts]
10+
exporter = "end_of_run_workflow:main"
11+
112
[tool.black]
213
line-length = 88
314
exclude = '''

0 commit comments

Comments
 (0)