-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat(controller): 8 - add command line interface for running on OSCAR #347
Closed
Closed
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
fd66870
feat: add typer
hollandjg 67c095a
docs: add import for class plus debug flags
hollandjg e0c8f36
chore: remove broken plot_utils for darts
hollandjg b4509e9
feat: add example running theorist
hollandjg 93b8d2e
feat: add example using parameters
hollandjg 48699b3
docs: updating docstrings
hollandjg 6d3b641
refactor: reorder file to match execution order
hollandjg a7be18b
refactor: reorder file to match execution order
hollandjg 3b23df3
feat: add ability to pre-set parameters of regressor
hollandjg d2f8d51
feat: rename output to model.pickle
hollandjg ec5e9a0
feat: add target run mode to controller
hollandjg d0f96d6
revert: remove run_fn
hollandjg 6926c82
chore: remove duplicated ExecutorName
hollandjg 3505613
chore: tighten types for HistorySerializer
hollandjg 9d741a3
chore: remove duplicated State type
hollandjg 9a7e765
chore: remove excess protocol
hollandjg f9628f6
chore: update type on serializer
hollandjg b5cfd49
chore: add example which has a real function
hollandjg d6c41da
feat: make step_name optional (use the controller default if supplied)
hollandjg 011b0d7
feat: make step_name optional (use the controller default if supplied)
hollandjg 11cd58a
feat: make step_name optional (use the controller default if supplied)
hollandjg 96259b6
refactor: reorder file
hollandjg 3b95527
refactor: separate out planner update function
hollandjg 69190cf
feat: add support for more types in executor
hollandjg 33c67ec
test: update random_state for random sample pooler
hollandjg f065249
docs: add warning about current path in controller
hollandjg b0afbb7
docs: add readme for custom function execution
hollandjg 26f26b1
docs: add example of running under cylc
hollandjg 6649e1a
docs: add readme
hollandjg 5df55db
deps: add pyyaml dependency
hollandjg a3fd8e5
deps: add func file
hollandjg 899398b
deps: add func file
hollandjg ba75e45
docs: add working slurm example
hollandjg 29da43c
try using variables for repeated values
hollandjg 639757b
Revert "try using variables for repeated values"
hollandjg df78a9d
docs: add example README for theorist
hollandjg 6a8a0e8
docs: add example README for theorist
hollandjg ceb92e0
Merge remote-tracking branch 'origin/feat/controller-cli' into feat/c…
hollandjg 0893f09
Update autora/controller/__main__.py
hollandjg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import logging | ||
import os | ||
import pathlib | ||
from typing import Optional | ||
|
||
import typer | ||
import yaml | ||
|
||
from autora.controller import Controller | ||
from autora.theorist.__main__ import _configure_logger | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def main( | ||
manager: pathlib.Path=typer.Argument(..., help="Manager path"), | ||
directory: pathlib.Path=typer.Argument(..., help="Directory path"), | ||
step_name: Optional[str] = typer.Argument(None, help="Name of step"), | ||
verbose: bool = typer.Option(False, help="Turns on info logging level."), | ||
debug: bool = typer.Option(False, help="Turns on debug logging level."), | ||
): | ||
_logger.debug("initializing") | ||
_configure_logger(debug, verbose) | ||
controller_ = _load_manager(manager) | ||
|
||
_logger.debug(f"loading manager state from {directory=}") | ||
controller_.load(directory) | ||
|
||
if step_name is not None: | ||
controller_ = _set_next_step_name(controller_, step_name) | ||
|
||
_logger.info("running next step") | ||
next(controller_) | ||
|
||
_logger.debug(f"last result: {controller_.state.history[-1]}") | ||
|
||
_logger.info("writing out results") | ||
controller_.dump(directory) | ||
|
||
return | ||
|
||
|
||
def _load_manager(path: pathlib.Path) -> Controller: | ||
_logger.debug(f"_load_manager: loading from {path=} (currently in {os.getcwd()})") | ||
with open(path, "r") as f: | ||
controller_ = yaml.load(f, yaml.Loader) | ||
assert isinstance( | ||
controller_, Controller | ||
), f"controller type {type(controller_)=} unsupported" | ||
return controller_ | ||
|
||
|
||
def _set_next_step_name(controller: Controller, step_name: str): | ||
_logger.info(f"setting next {step_name=}") | ||
controller.planner = lambda _: step_name | ||
return controller | ||
|
||
|
||
if __name__ == "__main__": | ||
typer.run(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the the
=
after the directory do?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that prints
"directory=<directory name>"
which otherwise you'd have to print like:f"directory={directory}"