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

New commands for CLI: sample-config, report-config, init, results ; Refactoring CLI #143

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

danrgll
Copy link
Collaborator

@danrgll danrgll commented Sep 17, 2024

  • neps sample-config --"worker_id" --number-of-configs <"int">
  • neps init --database; creates a neps state from e.g. run_config.yaml
  • neps report-config <"trial-id"> <"reported-as"> --loss --cost --duration --time-end --tb --err --learning-curve --"worker-id"
  • improve code maintenance
  • neps results --dump-all-configs <"format"> --dump-incumbents <"format">

@danrgll danrgll added the enhancement New feature or request label Sep 17, 2024
@danrgll danrgll changed the title [WIP]New commands for CLI: sample-config; Refactoring CLI [WIP]New commands for CLI: sample-config, report-config; Refactoring CLI Sep 18, 2024
@danrgll danrgll changed the title [WIP]New commands for CLI: sample-config, report-config; Refactoring CLI [WIP]New commands for CLI: sample-config, report-config, neps init --state-machine; Refactoring CLI Sep 18, 2024
@danrgll danrgll changed the title [WIP]New commands for CLI: sample-config, report-config, neps init --state-machine; Refactoring CLI New commands for CLI: sample-config, report-config, neps init --state-machine; Refactoring CLI Sep 18, 2024
neps/api.py Show resolved Hide resolved
neps/utils/cli.py Outdated Show resolved Hide resolved
neps/utils/cli.py Outdated Show resolved Hide resolved
neps/utils/cli.py Show resolved Hide resolved
neps/utils/cli.py Outdated Show resolved Hide resolved
neps/utils/cli.py Outdated Show resolved Hide resolved
@danrgll danrgll self-assigned this Sep 30, 2024
@danrgll danrgll changed the title New commands for CLI: sample-config, report-config, neps init --state-machine; Refactoring CLI New commands for CLI: sample-config, report-config, neps init, neps results ; Refactoring CLI Sep 30, 2024
@danrgll danrgll changed the title New commands for CLI: sample-config, report-config, neps init, neps results ; Refactoring CLI New commands for CLI: sample-config, report-config, init, results ; Refactoring CLI Sep 30, 2024
Comment on lines 80 to 113
root_dir = Path(args.root_directory)
if validate_directory(root_dir):
return root_dir
else:
return None

# Configuration file handling
config_path = Path("run_config.yaml")
if config_path.exists():
with config_path.open("r") as file:
config = yaml.safe_load(file)
try:
with config_path.open("r") as file:
config = yaml.safe_load(file)
except yaml.YAMLError as e:
print(f"Error parsing '{config_path}': {e}")
return None

root_directory = config.get(ROOT_DIRECTORY)
if root_directory:
root_directory_path = Path(root_directory)
if not root_directory_path.exists() or not root_directory_path.is_dir():
print(
f"Error: The directory {root_directory_path} does not exist or is "
f"not a "
f"directory."
)
if validate_directory(root_directory_path):
return root_directory_path
else:
return None
return root_directory_path
else:
raise ValueError(
"The config.yaml file exists but does not contain 'root_directory'."
print(
"Error: The 'run_config.yaml' file exists but does not contain the 'root_directory' key."
)
return None
else:
raise ValueError(
"Either the root_directory must be provided as an argument or config.yaml "
"must exist with a 'root_directory' key."
print(
"Error: 'root_directory' must be provided as a command-line argument "
"or defined in 'run_config.yaml'."
)
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

One thing that might make this a bit more informative is to call config_path = Path("run_config.yaml").resolve() and to use this path in the errors printed. Gives a bit more information on the complete path that is being looked for.

Comment on lines +633 to +634
trials = neps_state.get_all_trials()
sorted_trials = sorted(trials.values(), key=lambda x: int(x.id))
Copy link
Contributor

Choose a reason for hiding this comment

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

This actually silently fails as a config id for multifidelity is actually something like 9_1, which int("9_1") gets convereted to 91.

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
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants