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

Fix file not found error for get_preview script #381

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

codemonkey800
Copy link
Collaborator

I noticed there was an issue with the recent PR to napari-zelda resulting in the preview page throwing an error on build: https://github.com/RoccoDAnt/napari-zelda/runs/4719127633?check_suite_focus=true

Traceback (most recent call last):
  File "napari-hub/backend/get_preview.py", line 17, in <module>
    get_plugin_preview(repo_pth, dest_pth, args.local, args.branch)
  File "/home/runner/work/napari-zelda/napari-zelda/napari-hub/backend/preview/preview.py", line 48, in get_plugin_preview
    github_metadata = get_github_metadata(action_repo_url, branch=branch)
  File "/home/runner/work/napari-zelda/napari-zelda/napari-hub/backend/utils/github.py", line 123, in get_github_metadata
    citation_file = get_file(repo_url, "CITATION.cff", branch=branch)
  File "/home/runner/work/napari-zelda/napari-zelda/napari-hub/backend/utils/github.py", line 51, in get_file
    with open(os.path.join(local_workspace, file)) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/napari-zelda/napari-zelda/CITATION.cff'

It looks like this is because there isn't error handling for when a file doesn't exist in a local workspace 🤔

if local_workspace:
# read files locally since github action already checked it out
with open(os.path.join(local_workspace, file)) as f:
return f.read()

Adding exception handling for FileNotFoundError should fix the issue 😄

backend/utils/github.py Outdated Show resolved Hide resolved
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