Skip to content

Unite the argument order of artifact APIs#5533

Merged
HideakiImamura merged 10 commits intooptuna:masterfrom
nabenabe0928:code-fix/apply-convert-positional-to-upload-artifact
Jul 4, 2024
Merged

Unite the argument order of artifact APIs#5533
HideakiImamura merged 10 commits intooptuna:masterfrom
nabenabe0928:code-fix/apply-convert-positional-to-upload-artifact

Conversation

@nabenabe0928
Copy link
Copy Markdown
Contributor

@nabenabe0928 nabenabe0928 commented Jun 28, 2024

Motivation

This PR is to match the argument order of artifact store APIs.

Related PR:

Description of the changes

After this PR, the APIs will look:

def upload_artifact(*, artifact_store, file_path, study_or_trial,  ...) -> str:
    ...

def download_artifact(*, artifact_store, file_path, artifact_id) -> None:
    ...

Since upload_artifact is an existing API, I added convert_potional_args as a kind deprecation reminder for users.

@nabenabe0928 nabenabe0928 marked this pull request as draft June 28, 2024 09:12
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.79%. Comparing base (645bbf8) to head (f696936).
Report is 44 commits behind head on master.

Current head f696936 differs from pull request most recent head 49938e1

Please upload reports for the commit 49938e1 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5533      +/-   ##
==========================================
+ Coverage   89.76%   89.79%   +0.03%     
==========================================
  Files         197      197              
  Lines       12665    12666       +1     
==========================================
+ Hits        11369    11374       +5     
+ Misses       1296     1292       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nabenabe0928 nabenabe0928 marked this pull request as ready for review July 1, 2024 09:01
@nabenabe0928
Copy link
Copy Markdown
Contributor Author

@c-bata

I added the unittest for positional args. Do you think this test covers what you concerned?

@HideakiImamura
This PR is now review ready!

@HideakiImamura
Copy link
Copy Markdown
Member

@c-bata Could you review this PR?

@nabenabe0928 nabenabe0928 added the code-fix Change that does not change the behavior, such as code refactoring. label Jul 2, 2024
@nabenabe0928 nabenabe0928 added this to the v4.0.0 milestone Jul 2, 2024
Copy link
Copy Markdown
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Basically, LGTM. I have a minor comment. PTAL.

with open(file_path, "w") as f:
f.write("foo")

artifact_id = upload_artifact(trial, file_path, artifact_store) # type: ignore
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be great to catch the warning from convert_positional_args here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I addressed your comment!

@c-bata
Copy link
Copy Markdown
Member

c-bata commented Jul 2, 2024

@porink0424 Would you mind reviewing this PR instead of me?

@c-bata c-bata assigned c-bata and unassigned c-bata Jul 2, 2024
@c-bata c-bata removed their assignment Jul 2, 2024
Copy link
Copy Markdown
Member

@porink0424 porink0424 left a comment

Choose a reason for hiding this comment

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

LGTM👍

@nabenabe0928
Copy link
Copy Markdown
Contributor Author

@HideakiImamura could you merge this PR?

Copy link
Copy Markdown
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

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

I have an additional comment. PTAL.

Comment on lines +123 to +133
with pytest.warns(FutureWarning):
artifact_id = upload_artifact(trial, file_path, artifact_store) # type: ignore
_validate(artifact_id=artifact_id)
artifact_id = upload_artifact(
trial, file_path, artifact_store=artifact_store # type: ignore
)
_validate(artifact_id=artifact_id)
artifact_id = upload_artifact(
trial, file_path=file_path, artifact_store=artifact_store # type: ignore
)
_validate(artifact_id=artifact_id)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be better to catch the FutureWarning in each call of upload_artifact, since _validate does not cause any warnings.

Copy link
Copy Markdown
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

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

LGTM!

@HideakiImamura HideakiImamura enabled auto-merge July 4, 2024 00:38
@HideakiImamura HideakiImamura merged commit 2ffdf9c into optuna:master Jul 4, 2024
@nabenabe0928 nabenabe0928 deleted the code-fix/apply-convert-positional-to-upload-artifact branch June 5, 2025 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-fix Change that does not change the behavior, such as code refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants