-
Notifications
You must be signed in to change notification settings - Fork 4
POC hydra-intergration [do not merge] #30
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
base: main
Are you sure you want to change the base?
Conversation
| engine=get_engine(cfg.judge), | ||
| initial_prompt=JUDGE_PROMPT, | ||
| ) | ||
| storage = context.FileStorage(Path.cwd()) # Directory for storing contexts (structured logs) |
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.
When using hydra, we should just write directly to cwd since hydra auto-changes into a unique output directory for every experimental run
| return False | ||
|
|
||
|
|
||
| @hydra.main(config_path="conf", config_name="adversarial_prompting") |
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.
this tells hydra to look for a (yaml) config file at conf/adversarial_prompting.yaml
all the attributes specified in that config file become automatically available as CLI arguments
| log.info(f"Git diff:\n{diff}") | ||
|
|
||
|
|
||
| class SymbolicLinkCallback(Callback): |
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.
this is a slightly ugly (but working) hack to allow the current server implementation to work with the file structure generated by hydra
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.
Hydra generates the following structure
results/<timestamp1>/<timestamped_context_file>
results/<timestamp2>/<another_timestamped_context_file>
...
what this hack does is to just create symlinks for each context file and folder in the parent directory as follows
results/<timestamped_context_file> -> results/<timestamp1>/<timestamped_context_file>
results/<another_timestamped_context_file> -> results/<timestamp2>/<another_timestamped_context_file>
...
If the server/storage was able to just see the files one level below we could avoid that
|
|
||
| defaults: | ||
| - _self_ | ||
| - override hydra/launcher: joblib # joblib launches runs in parallel; comment out if undesired |
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.
parallel execution using joblib has some trouble with pydantic and pickling (see cloudpipe/cloudpickle#408) . the issue appears only if pydantic classes are defined in the main script. ==> to avoid the problem define all pydantic classes in a separate module and import them in your main script
| _log_git_sha() | ||
|
|
||
|
|
||
| def _log_git_sha(): |
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.
This is just, for now, just for discussion / knowledge sharing @gavento / @spirali
It shows a simple way of using hydra together with interlab.