Skip to content

Commit ccc9e1c

Browse files
committed
Force upgrade latest apex
1 parent 3a47016 commit ccc9e1c

3 files changed

Lines changed: 48 additions & 10 deletions

File tree

apex/skills/apex-flow/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Options to offer via AskQuestion:
107107
- If it exists, use `create` for a new job or `refresh-global` for an existing job; both convert the key to a fresh ticket and write it to `global.json`.
108108
- Verify that `global.json` contains a non-empty `bohrium_config.ticket` before submission.
109109
- `run.sh` must only install/verify APEX and call `apex submit`. Do not add ticket API calls or depend on `BOHRIUM_ACCESS_KEY` inside the APEX container.
110+
- Install with `python3 -m pip install --upgrade --no-cache-dir apex-flow`.
110111
See `reference/submission.md`.
111112
7. **Project ID from environment only.** `generate_config.py` reads `BOHRIUM_PROJECT_ID` (or `--project-id`). Never hardcode a project ID (including old examples like `13529`) into `global.json`, docs, or prompts.
112113
8. **Hard-validate inside the task directory before every upload.** Run:

apex/skills/apex-flow/reference/submission.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ APEX uses a **two-layer submission architecture**:
1717
1818
┌─────────────────────────────────────────────────────────────────┐
1919
│ Outer Bohrium Job (APEX image, c1_m2_cpu) │
20-
│ 1. pip install apex-flow (latest, no version pin)
20+
│ 1. pip install --upgrade --no-cache-dir apex-flow
2121
│ 2. apex submit param.json -c global.json -n "<wf-name>" │
2222
│ → Connects to workflows.deepmodeling.com │
2323
│ → Waits for completion and retrieves results automatically │
@@ -69,14 +69,11 @@ the job directory is packaged:
6969
7070
## Outer Job run.sh Template
7171

72-
The outer Bohrium job always uses this pattern. **Do NOT pin apex-flow version** — this ensures the latest code (with bug fixes) is used and propagated to inner steps via `upload_packages`.
73-
7472
```bash
7573
#!/bin/bash
7674
set -eo pipefail
7775

78-
# Always install latest apex-flow (DO NOT pin version)
79-
pip install apex-flow 2>&1 | tail -3
76+
python3 -m pip install --upgrade --no-cache-dir apex-flow 2>&1 | tail -5
8077
python3 -c "import apex; print(f'APEX version: {apex.__version__}')"
8178

8279
# Authentication is already stored in global.json by generate_config.py.
@@ -98,7 +95,7 @@ fi
9895
```
9996

10097
**Key points:**
101-
- `pip install apex-flow` (no `==` pin) → always gets latest from PyPI
98+
- Must use `pip install --upgrade --no-cache-dir apex-flow` (no `==` pin).
10299
- The installed APEX code is automatically sent to inner dflow steps via `upload_packages`
103100
- `run.sh` does not access `BOHRIUM_ACCESS_KEY` or modify `global.json`
104101
- **单次执行,不重试** — 失败即退出,由用户决定是否重新提交

apex/skills/apex-flow/scripts/generate_config.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -860,14 +860,54 @@ def main():
860860
json.dump(param_config, f, indent=4)
861861
print(f"Written: {param_path}")
862862

863-
# Write a submission helper script
864-
submit_script = output_dir / "submit.sh"
863+
# Write outer-job run.sh (force-upgrade APEX; bare pip install keeps the
864+
# image-bundled older version and uploads that stale code to inner steps).
865+
run_script = output_dir / "run.sh"
865866
cmd = f'apex submit param.json -c global.json -f {args.flow_type} -n "{workflow_name}"'
867+
with open(run_script, "w") as f:
868+
f.write("#!/bin/bash\n")
869+
f.write("set -eo pipefail\n\n")
870+
f.write("# Upgrade to latest apex-flow.\n")
871+
f.write(
872+
"python3 -m pip install --upgrade --no-cache-dir apex-flow "
873+
"2>&1 | tail -5\n"
874+
)
875+
f.write(
876+
'python3 -c "import apex; '
877+
'print(f\'APEX version: {apex.__version__}\')"\n\n'
878+
)
879+
f.write(
880+
"# Authentication is already stored in global.json by "
881+
"generate_config.py.\n"
882+
)
883+
f.write("set +eo pipefail\n")
884+
f.write(f"{cmd} 2>&1 | tee apex_submit.log\n")
885+
f.write("EXIT_CODE=${PIPESTATUS[0]}\n")
886+
f.write("set -eo pipefail\n\n")
887+
f.write("if [ $EXIT_CODE -eq 0 ]; then\n")
888+
f.write(
889+
' echo "=== APEX workflow completed and results retrieved ==="\n'
890+
)
891+
f.write(' echo "Retain apex_submit.log and the workflow ID."\n')
892+
f.write(" exit 0\n")
893+
f.write("else\n")
894+
f.write(' echo "APEX failed (exit $EXIT_CODE)"\n')
895+
f.write(" tail -50 apex_submit.log 2>/dev/null || true\n")
896+
f.write(" exit 1\n")
897+
f.write("fi\n")
898+
os.chmod(run_script, 0o755)
899+
print(f"Written: {run_script}")
900+
901+
# Keep a minimal submit.sh for local/debug use inside an already-upgraded env.
902+
submit_script = output_dir / "submit.sh"
866903
with open(submit_script, "w") as f:
867904
f.write("#!/bin/bash\n")
868-
f.write(f"# APEX submission command (run inside APEX container)\n")
905+
f.write("# APEX submission command (run inside APEX container)\n")
869906
f.write(f"# Workflow name: {workflow_name}\n")
870-
f.write(f"# Flow type: {args.flow_type}\n\n")
907+
f.write(f"# Flow type: {args.flow_type}\n")
908+
f.write(
909+
"# Prefer run.sh for Bohrium outer jobs (it upgrades apex-flow).\n\n"
910+
)
871911
f.write(f"{cmd}\n")
872912
os.chmod(submit_script, 0o755)
873913
print(f"Written: {submit_script}")

0 commit comments

Comments
 (0)