-
Notifications
You must be signed in to change notification settings - Fork 116
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
Support custom results/details push to hub #457
base: main
Are you sure you want to change the base?
Changes from all commits
2b0f03d
d0f1bad
a05258f
5151c99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,28 @@ def __init__( | |
|
||
self.public = public | ||
|
||
@property | ||
def results(self): | ||
config_general = asdict(self.general_config_logger) | ||
# We remove the config from logging, which contains context/accelerator objects | ||
config_general.pop("config") | ||
results = { | ||
"config_general": config_general, | ||
"results": self.metrics_logger.metric_aggregated, | ||
"versions": self.versions_logger.versions, | ||
"config_tasks": self.task_config_logger.tasks_configs, | ||
"summary_tasks": self.details_logger.compiled_details, | ||
"summary_general": asdict(self.details_logger.compiled_details_over_all_tasks), | ||
} | ||
return results | ||
|
||
@property | ||
def details(self): | ||
return { | ||
task_name: [asdict(detail) for detail in task_details] | ||
for task_name, task_details in self.details_logger.details.items() | ||
} | ||
|
||
def save(self) -> None: | ||
"""Saves the experiment information and results to files, and to the hub if requested.""" | ||
logger.info("Saving experiment tracker") | ||
|
@@ -281,6 +303,31 @@ def push_to_hub( | |
|
||
self.recreate_metadata_card(repo_id) | ||
|
||
def push_results_to_hub(self, repo_id: str, path_in_repo: str, private: bool | None = None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for |
||
repo_id = repo_id if "/" in repo_id else f"{self.hub_results_org}/{repo_id}" | ||
private = private if private is not None else not self.public | ||
self.api.create_repo(repo_id, private=private, repo_type="dataset", exist_ok=True) | ||
results_json = json.dumps(self.results, cls=EnhancedJSONEncoder, indent=2, ensure_ascii=False) | ||
self.api.upload_file( | ||
repo_id=repo_id, | ||
path_or_fileobj=results_json.encode(), | ||
path_in_repo=path_in_repo, | ||
repo_type="dataset", | ||
) | ||
|
||
def push_details_to_hub(self, repo_id: str, path_in_repo: str, private: bool | None = None): | ||
repo_id = repo_id if "/" in repo_id else f"{self.hub_results_org}/{repo_id}" | ||
private = private if private is not None else not self.public | ||
self.api.create_repo(repo_id, private=private, repo_type="dataset", exist_ok=True) | ||
for task_name, details in self.details: | ||
details_json = "\n".join([json.dumps(detail) for detail in details]) | ||
self.api.upload_file( | ||
repo_id=repo_id, | ||
path_or_fileobj=details_json.encode(), | ||
path_in_repo=path_in_repo.format(task_name=task_name), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you provide an example of the expected |
||
repo_type="dataset", | ||
) | ||
|
||
def recreate_metadata_card(self, repo_id: str) -> None: # noqa: C901 | ||
"""Fully updates the details repository metadata card for the currently evaluated model | ||
|
||
|
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.
Please add some doc, especially to explain the mechanism for the args you added (as they over-write some defaults set at the class level).
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.
Edit: just saw they were in your todo :)