Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

feat(postprocess): copy job metadata JSON to log directory for S3 upload#236

Open
KaunilD wants to merge 1 commit into
ishandhanani:mainfrom
KaunilD:kdhruv/copy-job-metadata-to-logs
Open

feat(postprocess): copy job metadata JSON to log directory for S3 upload#236
KaunilD wants to merge 1 commit into
ishandhanani:mainfrom
KaunilD:kdhruv/copy-job-metadata-to-logs

Conversation

@KaunilD

@KaunilD KaunilD commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Include {job_id}.json alongside config.yaml and sbatch_script.sh when copying artifacts into the log directory, so job metadata is preserved in S3 uploads.

Summary by CodeRabbit

  • New Features

    • Improved job artifact archival to include job ID metadata files alongside configuration and script files, providing more complete job documentation in log directories.
  • Tests

    • Added test coverage to verify job ID metadata files are correctly copied to log directories.

Include {job_id}.json alongside config.yaml and sbatch_script.sh when
copying artifacts into the log directory, so job metadata is preserved
in S3 uploads.

Made-with: Cursor
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The pull request extends the _copy_config_to_logs() method to copy an additional job artifact ({job_id}.json) to the log directory alongside existing config.yaml and sbatch_script.sh files. A corresponding unit test validates the new functionality.

Changes

Cohort / File(s) Summary
Implementation
src/srtctl/cli/mixins/postprocess_stage.py
Extended _copy_config_to_logs() to copy {job_id}.json by adding it to the artifacts list and constructing source/destination paths using self.runtime.job_id. Docstring updated to reflect the new artifact.
Test Coverage
tests/test_postprocess.py
Added test_copies_job_id_json unit test to verify the new {job_id}.json artifact is copied correctly to the log directory with matching JSON content.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A rabbit hops with joy today,
More artifacts now copy-way!
Job IDs tucked in JSON's fold,
Alongside configs, scripts bold—
S3 logs now richer told! 📦

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: copying job metadata JSON to the log directory for S3 uploads, which matches the primary objective of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/srtctl/cli/mixins/postprocess_stage.py (1)

299-300: ⚠️ Potential issue | 🟠 Major

Fix container_mounts type mismatch to unblock CI.

Line 299 and Line 441 pass str mount mappings, but start_srun_process expects dict[Path, Path] | None. This is currently failing type checks in CI.

💡 Suggested fix
-                container_mounts={str(self.runtime.log_dir): "/logs"},
+                container_mounts={self.runtime.log_dir: Path("/logs")},
...
-                container_mounts={str(self.runtime.log_dir): "/logs"},
+                container_mounts={self.runtime.log_dir: Path("/logs")},

Also applies to: 441-442

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/srtctl/cli/mixins/postprocess_stage.py` around lines 299 - 300, The
container_mounts argument is being passed as str mappings but start_srun_process
requires dict[Path, Path] | None; update the calls that set container_mounts
(e.g., where container_mounts={str(self.runtime.log_dir): "/logs"}) to construct
a dict[Path, Path] by converting both source and target to Path objects (e.g.,
Path(self.runtime.log_dir) -> Path("/logs") or Path("logs") as appropriate),
ensure pathlib.Path is imported if not already, and apply the same change to the
other occurrence that sets container_mounts so the types match
start_srun_process's signature.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/srtctl/cli/mixins/postprocess_stage.py`:
- Around line 299-300: The container_mounts argument is being passed as str
mappings but start_srun_process requires dict[Path, Path] | None; update the
calls that set container_mounts (e.g., where
container_mounts={str(self.runtime.log_dir): "/logs"}) to construct a dict[Path,
Path] by converting both source and target to Path objects (e.g.,
Path(self.runtime.log_dir) -> Path("/logs") or Path("logs") as appropriate),
ensure pathlib.Path is imported if not already, and apply the same change to the
other occurrence that sets container_mounts so the types match
start_srun_process's signature.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 73af19d0-9698-4061-9c0e-15375dcbad23

📥 Commits

Reviewing files that changed from the base of the PR and between f0a303b and 7ab747e.

📒 Files selected for processing (2)
  • src/srtctl/cli/mixins/postprocess_stage.py
  • tests/test_postprocess.py

gets uploaded alongside benchmark results and worker logs.
At submit time, config.yaml, sbatch_script.sh, and {job_id}.json are saved
to outputs/{job_id}/, but S3 syncs outputs/{job_id}/logs/. This copies them
into logs/ so they get uploaded alongside benchmark results and worker logs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you have to copy the files into /logs? Can you not also upload the files in the parent dir?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i think the original intention is to be selective about rolling up the logs and avoiding the bloat. this helps us marshal it. for example there can be a .venv or it can have dataset jsons that are irrelevant experiment tracking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for taking a look :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants