Repository navigation
Conversation
|
Well since you already did the work I don't see why not. Though I'd like to focus on getting done what we have left for 0.2 rather than adding new work :) (BTW I haven't actually reviewed this yet but I plan to) |
|
Well, if you look closely at the commits, I did much of the work months ago and just never issued a PR because I was planning on expanding it more (in ways I now think might have been unwise, anyway). So I'm not prioritizing this over other things, I promise :) |
|
Hey I'm not your boss, I'm not telling you how to spend your time :) I'm just anxious to get this release out. And I have tons to do myself >_> |
|
@mdboom @astrofrog, what do you think about this decorator? Do you want to use this approach for tagging optional dependencies? |
There was a problem hiding this comment.
Documentation bug: I assume 'scipy' and 'matplotlib' were supposed to be separate strings.
There was a problem hiding this comment.
Nevermind--I see now reading the code that this is supposed to work. The question is: Why have two ways to do it here?
There was a problem hiding this comment.
Fair enough... would you prefer 'scipy, matplotlib' or ['scipy', 'matplotlib']? (I think I prefer the former)
There was a problem hiding this comment.
I have a preference for the latter, because it requires less parsing, and is therefore less error-prone.
There was a problem hiding this comment.
Since the requires_optional_dependencies already takes variable arguments I figured one would just call it like requires_optional_dependencies('foo', 'bar', 'baz') This is much simpler and makes the single-string format superfluous. It will also be less error prone should we in the future add support for version specifiers and environment markers ;)
|
Lets move this discussion to the general comments so it doesn't get wiped out by commits, and may involve major changes... @iguananaut is concerned about using the wrapper, but I'm still not completely clear what the concern is: is it that you want all optional dependencies to be imported at the top of the module in which they are used? I think this is unwise because it will be very expensive to do this on import of major subpackages. Also, in that way of doing things, if you call a function that uses say, scipy, instead of getting an That said, I can see the argument for just completely eliminating the wrapper and instead just attaching the name of the optional dependency and just using @astrofrog - do you have thoughts on either of these items? |
|
The problem I have mainly comes down to the fact that the import is not attempted until the function that uses it is called. This in turn delays the user from finding out whether or not a required dependency is available, and could occur deep within some running code, rather than at startup time. I see the argument about importing optional dependencies slowing down initial imports. But so long as we just do top-level package imports such as There are other advantages to attempting to import dependencies immediately. For example the decorator can actually be used to update a function's docstring, such that if that function is missing one of its dependencies a big fat warning can be added to the top: "WARNING: This function depends on a missing package 'scipy' and is disabled." Or something of the like. Rather than raising an Alternatively, if you don't want to do the imports immediately, we could instead use Then you can still delay the actual import until the function is run. This will work on most modern Python installations. Though it's not guaranteed either, so if |
|
Hmm, I guess we just see things differently here. I think it's much better if when the users starts up astropy, it works as long as they have numpy, and they only start seeing errors about missing optional dependencies when they try to use them. That way if I just want astropy for, say, Of course, the point here is that we do want to keep track of optional dependencies for developer needs (e.g. listing them in the docs, making scripts that will install them if needed, etc). I wonder if maybe I should post this on astropy-dev given the lack of responses here? This seems a rather far-reaching question, potentially. |
|
Just to be sure, I think you might be misunderstanding me? And in that case I suppose that if the dependency isn't checked for until the function is run it could still come as a surprise. But this at least gives us the opportunity to warn the user that the function won't be available, either in the docstring (my preference) or maybe even with an (optional) warning message at import time. |
|
Right, that was what I thought you meant - I'm saying that doesn't solve the problem that this PR needs to solve - an automated way to identify all of astropy's opdeps, and causes the problem that the user then gets a vague So @iguananaut - I see a few options that we could do:
As that all the cases we've discussed here, or do you want to suggest another? Once we've got a clear set of options, I'll post to astropy-dev and hopefully we can pick one. |
|
@iguananaut - pinging you on the above discussion. If I don't hear from you soonish I'll just go-ahead and ask on astropy-dev |
|
Sorry, I've been traveling the last several days. I prefer a combination of option 3, and a class/function decorator that adds information to the docstring when the dependencies for that object are not met, plus any other instrumentation we may need/want, and to raise an exception that's more helpful than just an ImportError. Either way, I think this is worth bringing to the attention of astropy-dev if you haven't already. |
|
I totally thought I'd commented on this before, but apparently not... I think I would favor an approach where one would use a decorator that is just used to collect information about dependencies, but doesn't do anything magical. If developers have to follow a specific |
|
Thanks @astrofrog and @iguananaut - my preference is 2 because it seems simplest (and hence most likely that people will actually use it), and has the least performance impact, and fine-grained control of where the opdeps apply, but I also like @iguananaut's idea of also intelligently updating the docstring when it makes sense to do so. And I posted to astropy-dev, so we'll see what people say. |
|
@iguananaut @eteq - I feel like we should re-schedule this to 0.2.1 - it's not critical, as it's only going to be informational at this stage. |
|
@astrofrog - perhaps... the reason to include it now is that if we get a sudden increase in contributors after 0.2, we want them to start using this rather than having to go back by hand and fix it. But that's probably not a big deal because they would all be working from the dev version if they need this, anyway. And I may be overly-optimistic with the "sudden increase in contributors" scenario :) |
|
I don't think we need to worry about a sudden increase in contributions, and we'll want to limit contributions relying on optional dependencies anyway. I'm re-tagging this as 0.2.1 as we have enough major issues to deal with for 0.2.0. |
|
|
|
I don't really think this needs to be done by 0.3.0 so re-tagging as 0.4.0. Feel free to change back if you think it's ready and everyone agrees it should be merged. |
|
It may be that this should just be dropped completely, as the need for it hasn't really clearly materialized... perhaps if it doesn't seem necessary still by 0.4 we can just close it without merging. |
|
Sounds good! |
|
@eteq - just sorting through some old issues, since the need for this hasn't really come up since we last discussed it, shall we close? |
|
@astrofrog - Yeah, if it becomes a problem down the road if we accumulate non-scipy dependencies, we might resurrect it, but you're right at this point it seems unlikely. So closing! |
BLD: allow pre-releases to pass the python version check
Added Dunlap to Institutional Credits
This is an important step in completing #63 : a decorator to put around functions or methods that signifies they have an optional dependence.
This is not done, because I would need to go in and add it everywhere we use scipy and add something about it to the coding guidelines. But first I want to get some feedback: @iguananaut @mdboom @astrofrog, in particular: should we include this (in 0.2)?
Also, right now the only thing that does anything with the information in the decorators is the informational function included here (
find_all_optional_dependencies). But in 0.3 we would probably aim to add a tool to try to install these or at least report in the documentation what all the opdeps are.