Skip to content

fix(mkconcore): make the posix clear script empty every edge directory - #617

Open
Atharvsinh-codez wants to merge 1 commit into
ControlCore-Project:devfrom
Atharvsinh-codez:fix/posix-clear-every-volume
Open

Atharvsinh-codez wants to merge 1 commit into
ControlCore-Project:devfrom
Atharvsinh-codez:fix/posix-clear-every-volume

Conversation

@Atharvsinh-codez

Copy link
Copy Markdown

The posix clear script that mkconcore generates only empties the first edge directory.

Each edge gets a line like cd Y && rm -f *, and all of them run in the same shell. After the first line the script is still inside Y, so every later relative cd fails, its rm is skipped, and ./clear exits 1. The remaining edges keep their old data, so the next run of the study starts from stale values.

With demo/sample.graphml on dev:

#!/bin/bash
cd CU && rm -f *
cd PYM && rm -f *

./clear prints cd: PYM: No such file or directory, exits 1, and leaves everything in PYM.

This came in with 991373c (shell escaping), which replaced rm <edge>/* with the cd. I kept that approach and just run each line in a subshell, (cd CU && rm -f *), so the cd doesn't carry over. Windows (del /Q) and docker (docker volume rm) clear scripts don't cd, so they're not affected.

Changes:

  • mkconcore.py: wrap each posix clear line in a subshell (one line)
  • tests/test_cli.py: build a posix study with three file edges, run the generated build and clear, and check that every edge directory is empty and clear exits 0. It fails on dev and passes with this change. Skipped on Windows since it runs the bash scripts.

Verified with:

  • pytest (217 passed, 4 skipped)
  • built demo/sample.graphml with posix, put a file in each edge directory and ran ./clear: on dev PYM is left behind and the exit code is 1, with this change both are emptied and it exits 0
  • ruff format --check . and ruff check .

I used an AI assistant to help track this down and write the test. I've reviewed the change and run everything above myself.

The generated clear script runs `cd <edge> && rm -f *` once per edge in
the same shell, so after the first line it is still inside that edge's
directory. Every later relative cd fails and its rm is skipped: only the
first edge gets cleared and ./clear exits 1. This came in with the
shell-escaping change in 991373c, which replaced `rm <edge>/*`.

Run each line in a subshell so the cd does not carry over.
@github-actions

Copy link
Copy Markdown

🎉 Welcome aboard, @Atharvsinh-codez! Thank you for your first pull request in concore.

Please ensure that you are contributing to the dev branch.

Your contribution means a lot to us. We'll review it shortly.

Please ensure you have reviewed our:

If you have any questions, feel free to ask. Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant