Closed manthey closed 9 years ago
Can you give me an example of this scenario? I'm not quite clear on what you mean.
I have a file called cleverservice.py
that provides a service via run(). It has code like:
import tangelo
tangelo.paths(".")
import cleverutils
and then uses cleverutils.cleverfunction()
somewhere. If I alter cleverservice.py
and then hit the service again, Tangelo checks the file datestamp, sees that it is different, and reloads it. However, it doesn't do this for the cleverutils.py
module. This could be a good thing (as it allows maintaining state), or an annoying thing (as I have to restart Tangelo to reload the module after I change it).
If, instead I could call
import tangelo
tangelo.paths(".")
tangelo.module.get('cleverutils')
this could redo the import if the file time was different.
This broaches an important topic - rather than extend the "auto-reloading" feature to dependent modules like in this example, maybe we should scale back that behavior everywhere it already exists? The problem is, we've steadily moved toward making Tangelo more and more Pythonic, shrinking back from a lot of the cleverness I had baked in to start. In this case, that means I much prefer import cleverutils - which is Pythonic in the sense of having a universally recognizable meaning - to tangelo.module.get("cleverutils"), which could really mean almost anything, since it's a call to some Tangelo-specific functionality. One of the selling points of Tangelo is supposed to be that it's "just Python".
I realize the usefulness of the sort of runtime self-updating we're doing, but I think I put it in where it exists as a concession to developer-me, at the cost of compromising the usual Python semantics.
On Wed, Sep 2, 2015 at 11:40 AM David Manthey notifications@github.com wrote:
I have a file called cleverservice.py that provides a service via run(). It has code like:
import tangelo tangelo.paths(".") import cleverutils
and then uses cleverutils.cleverfunction() somewhere. If I alter cleverservice.py and then hit the service again, Tangelo checks the file datestamp, sees that it is different, and reloads it. However, it doesn't do this for the cleverutils.py module. This could be a good thing (as it allows maintaining state), or an annoying thing (as I have to restart Tangelo to reload the module after I change it).
If, instead I could call
import tangelo tangelo.paths(".") tangelo.module.get('cleverutils')
this could redo the import if the file time was different.
— Reply to this email directly or view it on GitHub https://github.com/Kitware/tangelo/issues/512#issuecomment-137137592.
Valid point @ronichoudhury, but I wonder if auto-load is one of those killer features of Tangelo that people like (and maybe some expect). I agree that people should be able to do "import cleverutils" with no magic but adding an optional API for advanced users who want the magical thing to work could be nice too.
That being said - grunt/gulp/etc. "watch" command can perform this type of reloading on file changes, so is this killer feature really killer? I lean toward yes because it does not rely on build systems and is a baked in nicety.
I'd say it's worth @manthey working on a PR so we can see if it is really messy/magic logic or if it is not so bad.
Sounds good to me.
On Mon, Sep 7, 2015 at 11:37 AM Jeffrey Baumes notifications@github.com wrote:
I'd say it's worth @manthey https://github.com/manthey working on a PR so we can see if it is really messy/magic logic or if it is not so bad.
— Reply to this email directly or view it on GitHub https://github.com/Kitware/tangelo/issues/512#issuecomment-138326729.
I've made a WIP PR for this with some commentary on the route I took. Feedback and criticism is welcome.
On Mon, Sep 7, 2015 at 1:33 PM, Jeffrey Baumes notifications@github.com wrote:
Assigned #512 https://github.com/Kitware/tangelo/issues/512 to @manthey https://github.com/manthey.
— Reply to this email directly or view it on GitHub https://github.com/Kitware/tangelo/issues/512#event-402965386.
David Manthey R&D Engineer Kitware Inc. (518) 881-4439
Thanks for looking into this - I will take a deep look soon.
On Tue, Sep 8, 2015 at 12:11 PM David Manthey notifications@github.com wrote:
I've made a WIP PR for this with some commentary on the route I took. Feedback and criticism is welcome.
On Mon, Sep 7, 2015 at 1:33 PM, Jeffrey Baumes notifications@github.com wrote:
Assigned #512 https://github.com/Kitware/tangelo/issues/512 to @manthey https://github.com/manthey.
— Reply to this email directly or view it on GitHub https://github.com/Kitware/tangelo/issues/512#event-402965386.
David Manthey R&D Engineer Kitware Inc. (518) 881-4439
— Reply to this email directly or view it on GitHub https://github.com/Kitware/tangelo/issues/512#issuecomment-138615960.
This has been thought out further and will become the --watch functionality. Closing this in favor of issue #516.
:+1:
Forgot to do something about this issue - thanks @manthey
If you import one service module from another, it remains loaded. This can be useful (to cache data, for instance), but for developing it would be nice if there was a way to flag a module to be 'unimported' after use, much like individual services.
I think the simplest way of doing this is to expose (and document) Tangelo.module.get() to modules that import tangelo.