Make a project to be a module by default
Closed this issue · 2 comments
Is your feature request related to a problem? Please describe.
I think the root problem is the fact that Revise.jl does not track files that are included in a file that is itself called using includet.
This causes some annoyances when I have a file script.jl file in my script folder and I want to call source code from files in src/.
When I work on a script, I like to include it with includet which allows me to modify the file without reloading it. But then my included files in src/ are not visible. After every modification of the files in src/, you have to restart the REPL which is very annoying. This problem was also described by a user on discourse in this post .
Describe the solution you'd like
The solution I use is the make the project a module as is described in the manual here.
This solves all the mentioned issues. It is now possible to add 'using MyProject' in my script files and calling the functions. Revise.jl works perfectly since MyProject is a legal julia project and can hence be loaded.
The feature I would love to have is that when a project is created, the module would be automatically created. Granted, this is a very small step to perform by hand, but currently the module solution lacks discoverability since:
- it is not obvious that this solves a big pain point with the use of includet
- it is just one of the many possible workflows.
My feature request is hence to make the module by default and advertise this workflow more prominently.
It is not clear for me whether this is breaking or not. I guess for people who don't use the module approach, everything should just work the same. But I do understand that this could be slightly disruptive.
Describe alternatives you've considered
As an alternative, maybe a modification of the documentation would be sufficient to reflect better the advantages of the module approach.
Thanks,
Olivier
My feature request is hence to make the module by default and advertise this workflow more prominently.
This has it's own disadvantages though. Firstly, it is a breaking change (and hence we can't do it as a default). However, for me there is another reason to (sometimes) prefer the non-module approach: re-compilation. At least in my cases, where I constantly change parts of the src
folder, each time I open up my project it gets recompiled if I use the module-as-project approach. This can take several minutes depending on the packages used.
What I would advocate, if you want to put in the time, is to make a Pull request that does two things:
- Advocate better the advantaes of the projec-as-module in the docs, as you mention.
- Add a keyword argument
module
toinitialize_project
thatn when true, it sets up the project so that there is the module structure alreay in place. However, the default value fo this keyword argument should befalse
.
Thanks a lot for your quick feedback.
Firstly, it is a breaking change (and hence we can't do it as a default)
That's indeed a strong argument against :-)
reason to (sometimes) prefer the non-module approach: re-compilation. At least in my cases, where I constantly change parts of the src folder, each time I open up my project it gets recompiled if I use the module-as-project approach.
Aha, I hadn't thought of that. That would be very annoying indeed.
What I would advocate, if you want to put in the time, is to make a Pull request
Great suggestions. I will give it a try since it would be my first pull request ever.
Thanks again!