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

Error when using a file in a git repository as an asset in spacy projects config #66

Closed
b2m opened this issue Jan 24, 2023 · 2 comments · Fixed by #83
Closed

Error when using a file in a git repository as an asset in spacy projects config #66

b2m opened this issue Jan 24, 2023 · 2 comments · Fixed by #83
Labels
bug Something isn't working

Comments

@b2m
Copy link

b2m commented Jan 24, 2023

Using a file in a git repository as an asset in a spacy project configuration fails because the code expects only directories.

How to reproduce the behaviour

Use a file in a git repository as an asset in the projects.yml as described in the documentation:

path: Path of the file or directory to download, relative to the repo root.

Here is a code example trying to use spacy's citation file as an asset:

assets:
  - dest: "spacy-citation.cff"
    git:
      repo: "https://github.com/explosion/spaCy"
      branch: "master"
      path: "CITATION.cff"

Then run spacy project assets which fails with the following (reduced) stacktrace:

Traceback (most recent call last):
 ...
  File "/venv/lib/python3.8/site-packages/spacy/cli/project/assets.py", line 39, in project_assets_cli
    project_assets(
  File "/venv/lib/python3.8/site-packages/spacy/cli/project/assets.py", line 105, in project_assets
    git_checkout(
  File "/venv/lib/python3.8/site-packages/spacy/cli/_util.py", line 407, in git_checkout
    shutil.copytree(str(source_path), str(dest))
  File "/usr/lib/python3.8/shutil.py", line 555, in copytree
    with os.scandir(src) as itr:
NotADirectoryError: [Errno 20] Not a directory: '/tmp/tmpw_23425/CITATION.cff'

The reason for the error is that shutil.copytree expects a directory and not a single file.

Your Environment

  • Operating System: Ubuntu 20.04
  • Python Version Used: 3.8.10
  • spaCy Version Used: 3.4.4
@danieldk danieldk added the bug Something isn't working label Jan 24, 2023
@danieldk
Copy link

Thank you for reporting this issue! I can reproduce it and am currently working on a fix.

danieldk referenced this issue in danieldk/spaCy Jan 25, 2023
Our Git fetcher code assumed that the asset to be copied was a
directory. Support files as well and add tests to check both the file
and directory cases.

Fixes #12168.
danieldk referenced this issue in danieldk/spaCy Jan 25, 2023
Our Git fetcher code assumed that the asset to be copied was a
directory. Support files as well and add tests to check both the file
and directory cases.

Fixes #12168.
@adrianeboyd adrianeboyd transferred this issue from explosion/spaCy Oct 10, 2023
@adrianeboyd
Copy link
Contributor

We would need to port explosion/spaCy#12181 to weasel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants