Skip to content

feat(config): route SEvt output directory through app config#322

Merged
plexoos merged 9 commits into
mainfrom
refactor-output-dir-config
May 13, 2026
Merged

feat(config): route SEvt output directory through app config#322
plexoos merged 9 commits into
mainfrom
refactor-output-dir-config

Conversation

@plexoos
Copy link
Copy Markdown
Member

@plexoos plexoos commented May 7, 2026

This PR makes gphox::Config the authoritative source for runtime configuration parameters that are applied to supported binaries execution. The main focus is refactoring event runtime controls, especially event.mode and event.output_dir, so they are read from the app config JSON and then synchronized into SEventConfig from one place.

  • Added --config support to the affected binaries so runtime behavior can be selected via config file.
  • Updated tests/scripts to use the config-controlled output location instead of relying on fake USER/GEOM environment setup.
  • Eliminated the need to set USER and GEOM environment variables for the supported binaries/tests that now route output through Config.

@plexoos plexoos force-pushed the refactor-output-dir-config branch from e0a5711 to e3432c3 Compare May 7, 2026 17:12
@plexoos plexoos self-assigned this May 7, 2026
@plexoos plexoos force-pushed the refactor-output-dir-config branch from e3432c3 to 967e5d6 Compare May 7, 2026 18:29
@plexoos plexoos marked this pull request as ready for review May 7, 2026 19:09
@plexoos plexoos requested review from Copilot and ggalgoczi May 7, 2026 19:09
@plexoos plexoos added the enhancement New feature or request label May 7, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 967e5d6a97

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config.cpp
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors event output directory selection so that application-level JSON config (via gphox::Config) can drive SEvt output folder placement by synchronizing settings into SEventConfig.

Changes:

  • Add event.output_dir support to gphox::Config and apply it via SEventConfig::SetOutFold.
  • Update SEvt::DefaultBase to honor explicit SEventConfig::OutFold() overrides when determining the base output path.
  • Update example/test executables and scripts to use config-driven behavior (plus bump project C++ standard to C++20).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_simg4ox.sh Stops forcing fake USER/GEOM, adds set -e, quotes paths.
tests/test_GPURaytrace.sh Removes fake USER/GEOM env-prefix for execution.
tests/test_GPUPhotonSource_8x8SiPM.sh Removes fake USER/GEOM env-prefix for execution.
tests/test_GPUPhotonFileSource.sh Removes fake USER/GEOM env-prefix for execution.
tests/compare_ab.py Adds --base to locate event folders under a configurable root.
sysrap/SEvt.cc Routes DefaultBase() through explicit OutFold overrides when present.
src/GPURaytrace.cpp Adds --config and constructs gphox::Config to apply config.
src/GPUPhotonFileSource.cpp Adds --config and constructs gphox::Config to apply config.
src/GPUCerenkov.cpp Adds --config and constructs gphox::Config to apply config.
src/config.h Introduces EventMode, plus config fields/methods for applying event policy.
src/config.cpp Implements event mode parsing, output dir reading, and Apply() syncing to SEventConfig.
config/dev.json Adds event.output_dir (set to /tmp).
CMakeLists.txt Raises project C++ standard to C++20; sets CUDA standard to 17.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/config.cpp Outdated
Comment thread src/config.cpp
Comment thread src/GPURaytrace.cpp Outdated
Comment thread src/GPUCerenkov.cpp Outdated
Comment thread src/GPUPhotonFileSource.cpp Outdated
Comment thread CMakeLists.txt
Comment thread src/config.cpp Outdated
Copy link
Copy Markdown
Contributor

@ggalgoczi ggalgoczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Config::Apply() unconditionally overrides SEventConfig::OutFold. wipes any OPTICKS_OUT_FOLD env, bypasses the $TMP/GEOM/$GEOM/$Exec controlled-dir flow, dumps SEvt output in cwd whenever a config lacks event.output_dir.
    This is a problem for all 6 binaries.

Commands that break on PR #322 HEAD:

OPTICKS_OUT_FOLD=/data/run42 simg4ox -g foo.gdml -m run.mac    # env override silently wiped → cwd
GEOM=mygeom USER=alice simg4ox -g foo.gdml -m run.mac   # controlled-dir flow bypassed → cwd
simg4ox -g foo.gdml -m run.mac -c sphere_leak           # config has no output_dir → cwd
GPUPhotonSource -g 8x8.gdml -c 8x8SiPM_crystal -m run.mac            # same → cwd
cd /home/alice && simg4ox -c wls_test ...      # writes A000/B000/ into $HOME
  1. storch torch left uninitialized when JSON omits the torch section, primitives are indeterminate, generate_photons(cfg.torch) reads UB. Commented on specific lines.
    Command that breaks:
GPHOX_CONFIG_DIR=/tmp simg4ox -c notorch -g foo.gdml -m run.mac      # generate_photons reads uninit struct
  1. Generic catch (std::exception&) too broad, it swallows filesystem and any non-JSON throws under "Failed reading config parameters."

Some more non-blockers:

  1. gphox::EventMode duplicates SEventConfig's mode strings. src/config.h:13-23 mirrors sysrap/SEventConfig.hh:387-394. Drift risk if sysrap adds a mode. Suggest driving EventModeInfos at src/config.cpp:37-46 off SEventConfig::Minimal etc. directly.
  2. config/dev.json:28 ships "output_dir": "/tmp": concurrent users on one host collide at /tmp/ALL0_no_opticks_event_name/.

Questions:

  • Is the OPTICKS_OUT_FOLD env-var override regression intentional?
  • Why is dev.json shipping a host-wide /tmp instead of a per-user path?

@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented May 8, 2026

Commands that break on PR #322 HEAD:

That is exactly the motivation behind this PR — rely only on the config file to control the output dir and other runtime parameter and dont' use env vars

@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented May 8, 2026

  • Is the OPTICKS_OUT_FOLD env-var override regression intentional?

yes, all parameters should be defined via json configs

  • Why is dev.json shipping a host-wide /tmp instead of a per-user path?

Agree and switched to the current directory by default. The user can set it to any path via a config file.

@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented May 8, 2026

3. Generic catch (std::exception&) too broad, it swallows filesystem and any non-JSON throws under "Failed reading config parameters."

changed to std::invalid_argument

@plexoos plexoos requested a review from ggalgoczi May 8, 2026 17:29
@plexoos plexoos force-pushed the refactor-output-dir-config branch from 1466af0 to c1a0a63 Compare May 8, 2026 19:21
@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented May 8, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1a0a630e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config.cpp
@ggalgoczi
Copy link
Copy Markdown
Contributor

The direction (config-only over env vars) is a good one, but only if all env variables eventually move to JSON; otherwise developers have to keep two mental models (env + JSON) to predict a run, which is worse than either extreme. Reproducibility-affecting knobs like OPTICKS_MAX_BOUNCE, the four OPTICKS_PROPAGATE_EPSILON*, OPTICKS_EVENT_MODE, OPTICKS_HIT_MASK, and OPTICKS_MAX_RECORD all change physics outcomes and need to be in the config for the single-source-of-truth claim to hold. What's your plan for migrating the rest?

@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented May 11, 2026

What's your plan for migrating the rest?

The plan is to migrate the rest gradually over time. You are welcome to help of course.

plexoos and others added 8 commits May 11, 2026 11:27
This branch refactors output directory handling so app-level JSON config can control where event
folders are written, instead of relying only on default `SEventConfig` behavior/env vars.

- Centralize runtime output path control in the application config layer.
- Make output location explicit and reproducible across binaries.
- Reduce dependence on ad-hoc env setup in test and local runs.

If `event.output_dir` is set, SEvt output folders are rooted there.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@plexoos plexoos force-pushed the refactor-output-dir-config branch from c1a0a63 to c3a2829 Compare May 11, 2026 15:31
@plexoos
Copy link
Copy Markdown
Member Author

plexoos commented May 12, 2026

@ggalgoczi Do you have any other questions?

@plexoos plexoos merged commit a2a292d into main May 13, 2026
13 checks passed
@plexoos plexoos deleted the refactor-output-dir-config branch May 13, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants