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

FEA Utility function to add arbitrary files to the repo #123

Merged
merged 15 commits into from
Sep 5, 2022

Conversation

BenjaminBossan
Copy link
Collaborator

@BenjaminBossan BenjaminBossan commented Aug 31, 2022

Solves #111

This is the outcome of using plot_hf_hub.py with one added line:

hub_utils.add_files([__file__], dst=local_repo)

As can be seen, the script itself is now included in the upload.

@BenjaminBossan
Copy link
Collaborator Author

@skops-dev/maintainers

Could you help me figure out why the new tests are failing? The offending code seems to stem from this fixutre:

https://github.com/BenjaminBossan/skops/blob/adding-files/skops/hub_utils/tests/test_hf_hub.py#L497-L510

which results in the error OSError: Model file '/tmp/.../model.pickle' does not exist.

This seems odd to me because the tests pass locally and because I'm doing basically exactly the same as, e.g., this test, which succeeds.

- The test_inference tests had a side effect on all subsequent tests
  because they were cleaning up the directory which is being re-used.
  Now they get to have their own directory.
- Wrong file name in tests for adding files
@BenjaminBossan
Copy link
Collaborator Author

@skops-dev/maintainers The PR is ready for review now.

The error mentioned above was caused by test_inference doing some cleanup that would disrupt tests running later. We use some session-scoped fixtures, resulting in this dependency. My solution was to have test_inference run in a different directory in order for it not to interfere with other tests. Alternatively, we could reduce the scope of the used fixtures, but that would slow the tests down.

Regarding the failed codecov check: I have covered all new lines with tests, so this is a false positive. It seems that codecov thinks that my changes affect the coverage of get_model_output (see very last line):

https://app.codecov.io/gh/skops-dev/skops/compare/123/tree/skops/hub_utils/_hf_hub.py#D1L634

This is probably caused by this CI run not randomly failing when calling inference API, so it's a fluke.

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

first look, haven't checked the tests yet.

docs/changes.rst Outdated Show resolved Hide resolved
skops/hub_utils/_hf_hub.py Outdated Show resolved Hide resolved
Comment on lines 367 to 371
msg = (
"First argument must be a sequence of str or Path, got "
f"{type(files)} instead."
)
raise TypeError(msg)
Copy link
Member

Choose a reason for hiding this comment

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

even if we stick with the current signature, I think we should accept a simple string or Path here.

skops/hub_utils/_hf_hub.py Outdated Show resolved Hide resolved
BenjaminBossan and others added 3 commits September 1, 2022 16:13
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
- Make files *args
- Add exist_ok parameter
@BenjaminBossan
Copy link
Collaborator Author

@adrinjalali Yes, I was thinking about making files *args too, I changed it as suggested. Furthermore, I added an exist_ok argument (default True). If the file exists and exist_ok=True, I'll now overwrite it (instead of skipping like previously) and if exist_ok=False raise an error.

I was also thinking about adding directories but if we want that, let's do it in another PR.

CI does not retain logs :(
Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

skops/hub_utils/_hf_hub.py Outdated Show resolved Hide resolved
skops/hub_utils/_hf_hub.py Outdated Show resolved Hide resolved
skops/hub_utils/_hf_hub.py Outdated Show resolved Hide resolved
Whether it's okay or not to add a file that already exists. If it's
okay, override the file, otherwise raise a ``FileExistsError``.

Raises
Copy link
Member

Choose a reason for hiding this comment

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

nit: copy2 might also raise due to permission issues, but I'm okay not listing them here.

Copy link
Collaborator Author

@BenjaminBossan BenjaminBossan Sep 5, 2022

Choose a reason for hiding this comment

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

When the copy2 function is used elsewhere, we also don't mention that error. Not sure if we should document any possible error our functions could raise or only those we explicitly raise in the function body?

BenjaminBossan and others added 3 commits September 5, 2022 11:14
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
@adrinjalali adrinjalali changed the title Utility function to add arbitrary files to the repo FEA Utility function to add arbitrary files to the repo Sep 5, 2022
@adrinjalali adrinjalali merged commit f60c248 into skops-dev:main Sep 5, 2022
@BenjaminBossan BenjaminBossan deleted the adding-files branch September 5, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants