Skip to content

fix(#143): Replace hardcoded absolute paths with argparse + YAML config#202

Open
vignathi123-vi wants to merge 1 commit intoML4SCI:mainfrom
vignathi123-vi:fix/143-hardcoded-paths-yaml-config
Open

fix(#143): Replace hardcoded absolute paths with argparse + YAML config#202
vignathi123-vi wants to merge 1 commit intoML4SCI:mainfrom
vignathi123-vi:fix/143-hardcoded-paths-yaml-config

Conversation

@vignathi123-vi
Copy link
Copy Markdown

Fixes #143

Problem
Three scripts had hardcoded absolute paths pointing to the original developer's
machine, making them completely non-functional for anyone else.

Files Changed
inference.py — replaced hardcoded log_dir and finetune_model_path
finetune_byol.py — replaced hardcoded saved_model_path
finetune.py — replaced hardcoded saved_model_path

What this PR adds beyond existing PRs (#144, #169)
YAML config files for all 3 scripts inside config/yaml/ as suggested by mentors
--config flag to point to any custom config file
Path validation with clear FileNotFoundError messages so users know exactly what is missing
CLI args override YAML values so both workflows are supported
num_workers, split_ratio, dataset_name also moved to config

Usage after fix

# Option 1 — edit the YAML config file, then run:
python inference.py

# Option 2 — pass paths directly via CLI:
python inference.py --log_dir logger/my_run --finetune_model_path logger/my_run/checkpoint/model.pt

# Option 3 — point to a custom config file:
python inference.py --config path/to/my_config.yaml

@likitha487
Copy link
Copy Markdown

happy to make further improvements based on feedback

@likitha487
Copy link
Copy Markdown

Added support for configurable paths using argparse and optional YAML config.
This removes hardcoded paths and improves flexibility and reproducibility.

@vignathi123-vi
Copy link
Copy Markdown
Author

vignathi123-vi commented Mar 25, 2026

Thanks for your contribution @likitha487.
This PR goes a bit further by implementing full YAML configuration support across all three scripts, along with a --config flag, CLI override capability, and explicit path validation for clearer error handling.
These additions align with mentor suggestions and aim to improve flexibility, reproducibility, and overall usability.
Happy to incorporate any specific suggestions if you have further improvements in mind.

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.

{Bug] Hardcoded Absolute Paths in BYOL/Inference Scripts (Transformers Classification DeepLense)

2 participants