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

ENH: Don't list resources if loading a known resource fails #309

Merged
merged 2 commits into from
Oct 18, 2018

Conversation

kyleam
Copy link
Contributor

@kyleam kyleam commented Oct 16, 2018

Usually importing a resource fails because the user has passed an
unknown resource type, so we report the known resources in the
exception message. But if the import of a known resource fails (e.g.,
because the resource imports an uninstalled module), it's confusing to
show a list of known resources.

Closes #297.

Usually importing a resource fails because the user has passed an
unknown resource type, so we report the known resources in the
exception message.  But if the import of a known resource fails (e.g.,
because the resource imports an uninstalled module), it's confusing to
show a list of known resources.

Closes ReproNim#297.
@codecov
Copy link

codecov bot commented Oct 16, 2018

Codecov Report

Merging #309 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
+ Coverage   88.59%   88.63%   +0.04%     
==========================================
  Files         133      133              
  Lines        9582     9635      +53     
==========================================
+ Hits         8489     8540      +51     
- Misses       1093     1095       +2
Impacted Files Coverage Δ
niceman/resource/base.py 92.67% <100%> (-1.26%) ⬇️
niceman/resource/singularity.py 88.78% <0%> (-0.11%) ⬇️
niceman/resource/shell.py 97.26% <0%> (-0.08%) ⬇️
niceman/resource/docker_container.py 95.33% <0%> (-0.07%) ⬇️
niceman/resource/tests/test_base.py 100% <0%> (ø) ⬆️
niceman/interface/tests/test_create.py 100% <0%> (ø) ⬆️
niceman/resource/tests/test_session.py 99.51% <0%> (+0.04%) ⬆️
niceman/interface/create.py 95.23% <0%> (+0.5%) ⬆️
niceman/resource/ssh.py 91.39% <0%> (+0.67%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 694b155...3512e4b. Read the comment docs.

@@ -134,10 +134,12 @@ def factory(config):
except Exception as exc:
# Typically it should be an ImportError, but let's catch and recast
# anything just in case.
msg = exc_str(exc)
known = ResourceManager._discover_types()
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't be surprised if we manage to raise exception there as well, so may be try/except these 3 lines as well and add caught exception message (msg += " Failed to discover resource types: %s" % exc_str(exc2)) in except for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like an overkill to me, but as you wish.

@yarikoptic yarikoptic merged commit 55dcd22 into ReproNim:master Oct 18, 2018
@yarikoptic
Copy link
Member

Thanks!

@kyleam kyleam deleted the enh-known-resource-err branch October 19, 2018 02:30
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