Implement "attach" command and graceful exiting
- Dominant language
- Python
- Stars
- 12
- Forks
- 6
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 2
Description
The target is to implement (mecha)babs support for monitoring entire subject processing job script, so we could do smth like (expressing)
```patch
diff --git a/code/participant_job.sh b/code/participant_job.sh
index a49142d..c071ce2 100755
--- a/code/participant_job.sh
+++ b/code/participant_job.sh
@@ -6,6 +6,9 @@
#SBATCH --time=24:00:00
+DUCT_PREFIX="logs/duct_${subid}_" con-duct attach &
+duct_pid=$!
+
# shellcheck disable=SC1091
source /dartfs/rc/lab/D/DBIC/DBIC/CON/asmacdo/mechababs/.venv/bin/activate
@@ -109,7 +112,6 @@ if [ ! -L "${CONTAINER_JOB}" ]; then
exit 1
fi
-export DUCT_PREFIX="logs/duct_${subid}_"
# Step 1: Run BIDS app via containers-run
datalad containers-run \
@@ -156,4 +158,7 @@ echo '# Push the branch with provenance records:'
# shellcheck disable=SC2154
flock "${DSLOCKFILE}" git push outputstore "${BRANCH}"
-echo SUCCESS
\ No newline at end of file
+
+kill "$duct_pid" # inform to gracefully exit
+
+echo SUCCESS
```
docstring for `attach` would tell user to use `kill` potentially with specific signal (9 or INT) as to e.g. trigger killing without graceful shutdown which should happen on default `kill` which is TERM (15).
and `attach` will just monitor current session (like we have `run --session=current`) and not require a command to run
Contributor guide
Research direction
Start with the code/participant_job.sh example and compare the requested attach behavior with the existing run --session=current mode. Trace the attach command entry point and determine how it monitors the current session without a command. Done means the session can be stopped gracefully with the default signal, while the docstring explains how stronger signals affect shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100