Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add structured configs to hydra cli, pass cfg to runners #976

Merged
merged 15 commits into from
Jan 23, 2025

Conversation

rayg1234
Copy link
Collaborator

@rayg1234 rayg1234 commented Jan 18, 2025

  1. Removes hydra_cli and cli dependency and splits them into two different clis
    The new cli will be called like:
    fairchemv2 --config-yml /path/to/yaml [hydra-like config overides]

This removes the old arg flags completely and moves them into FairchemJobConfig as a structured config:

Users are free to specify the either in the yaml or in the command line as they choose
in yaml:

job:
  scheduler:
    num_ranks_per_node: 4

runner:

logger:

in command line:
fairchemv2 --config-yml /path/to/yaml +job.scheduler.num_ranks_per_node=4

  1. Pass the job config to the runner as a property, the runner still some needs some system level params such as run_dir
    ie: runner.fairchem_config

Former-commit-id: e0efe32af1cf098a08f22f77c3923bbf65f95622
@rayg1234 rayg1234 requested a review from lbluque January 18, 2025 01:09
@rayg1234 rayg1234 added the enhancement New feature or request label Jan 18, 2025
@lbluque lbluque added the minor Minor version release label Jan 19, 2025
Copy link
Collaborator

@lbluque lbluque left a comment

Choose a reason for hiding this comment

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

This is looking great! thanks @rayg1234

Comment on lines 66 to 73
class FairchemJobConfig:
run_name: str = field(default_factory=lambda: uuid.uuid4().hex.upper()[0:8])
timestamp_id: str = field(default_factory=lambda: get_timestamp_uid())
run_dir: str = field(default_factory=lambda: tempfile.TemporaryDirectory().name)
log_dir: str = "logs"
device_type: DeviceType = DeviceType.CUDA
debug: bool = False
scheduler: SchedulerConfig = field(default_factory=lambda: SchedulerConfig)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The current trainer records the commit hash + version being used. Would be nice to keep that. (We technically only need the commit hash since the version has it, but no harm in keeping both)

"commit": commit_hash,
"version": __version__,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let me think about where to log these, we should retain these tho they arent exactly input config params

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 90.76923% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fairchem/core/_cli_hydra.py 94.54% 3 Missing ⚠️
src/fairchem/core/components/runner.py 70.00% 3 Missing ⚠️
Files with missing lines Coverage Δ
src/fairchem/core/_cli.py 66.15% <ø> (-1.97%) ⬇️
src/fairchem/core/common/flags.py 100.00% <ø> (ø)
src/fairchem/core/_cli_hydra.py 83.33% <94.54%> (+13.59%) ⬆️
src/fairchem/core/components/runner.py 79.41% <70.00%> (-4.59%) ⬇️

Copy link
Collaborator

@lbluque lbluque left a comment

Choose a reason for hiding this comment

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

lg @rayg1234, just a minor suggestion and question

src/fairchem/core/components/runner.py Outdated Show resolved Hide resolved
@@ -31,6 +44,7 @@ def __init__(self, x: int, y: int):
self.y = y

def run(self) -> Any:
assert hasattr(self, "fairchem_config")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this assert ever false? seems superfluous using @property

Copy link
Collaborator Author

@rayg1234 rayg1234 Jan 22, 2025

Choose a reason for hiding this comment

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

oh ya true

Copy link
Collaborator

@lbluque lbluque left a comment

Choose a reason for hiding this comment

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

lgtm

@rayg1234 rayg1234 enabled auto-merge January 23, 2025 00:29
@rayg1234 rayg1234 added this pull request to the merge queue Jan 23, 2025
Merged via the queue into main with commit d513ffa Jan 23, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor Minor version release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants