-
Notifications
You must be signed in to change notification settings - Fork 1
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
Transition from Requires.jl to v1.9-style weak dependencies #42
Conversation
I like the move towards I think the "drawbacks", if you can call it that, of having to either extend methods of the loaded extension or of the main package, are nothing really major. I don't see any pain points there. As for providing backward compatibility with pre |
Codecov Report
@@ Coverage Diff @@
## main #42 +/- ##
==========================================
+ Coverage 72.42% 72.59% +0.17%
==========================================
Files 10 10
Lines 747 748 +1
==========================================
+ Hits 541 543 +2
+ Misses 206 205 -1
|
This should be more or less complete now. Since extension modules are not directly available, documenting the interface they introduce proved to be a bit more involved than expected, but all examples and docs should now be up-to-date with the new way of doing things. One thing we'll have to do at some point before the next release: update
|
LGTM (there is one lingering reference to Requires in the Edit: I went ahead and fixed it, as well as a few typos. |
Should we discuss some other (minor) improvements for |
@@ -1,6 +1,7 @@ | |||
[deps] | |||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" | |||
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" | |||
DataFlowTasks = "d1549cb6-e9f4-42f8-98cc-ffc8d067ff5b" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never add the project itself as a dependency to docs
, as I was under the impression this was not necessary (Documenter
looks into its parent folder for a project right?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Documenter
looks into its parent folder to find the documented project, so at the time when the documentation is built, the parent package has to be present in the documentation environment in some way. However, one of the steps in the GitHub CI action takes care of Pkg.dev
ing the parent project in the documentation subproject. So both ways work: if the committed docs/Project.toml
does not mention DataFlowTasks
, things will get set up correctly just ahead of time.
I've recently seen packages where even the docs/Manifest.toml
was committed so as to make sure that the parent project is dev
ed from the parent directory. Graphs.jl
is an example of this.
Personally, I'd be in favor of keeping DataFlowTasks
as a documentation dependency in the committed docs/Project.toml
, because this simplifies the process to locally build the documentation. But I'm open to compromise 😄
Can we go ahead and merge this? |
Yes, we can merge this. The only unresolved issue is related to the docs dependencies, so nothing specific to the weakdeps transitions and we can decide later. I'm going to mention this in #43 so that we don't forget to decide about this. |
Now that 1.9 allows for "weak dependencies", I wanted to test whether we could use these to handle optional dependencies to GraphViz & Makie for visualization.
This is (the beginning of) an attempt to do this. It's not finished (yet), but I wanted to discuss this as early as possible in order to make an informed decision about where we go with this.
One first thing to note is that it is nice to have these TTFX-heavy workloads inside precompileable modules. The drawback is that these modules are "insulated" from
DataFlowTasks
: the visualization code used to be able to use anything fromDataFlowTasks
, and also used to be able to define new functions inside theDataFlowTasks
namespace. This is not the case anymore; the good practice seems to use extension code to add methods to existing functions, which requires our old Requires-based code to be updated in one of two ways (there might also be more ways to do things that I haven't thought about):Makie
/GraphViz
. For example, I replaced our customplot_traces
andplot_dag
with new methods forMakie.plot
andGraphViz.Graph
. Below is an excerpt from the updatedREADME
(other examples are not up-to-date):DataFlowTasks
itself. This means thatDataFlowTasks
might define functions which are available but unusable at first because they have no method until an extension is loaded. I did this for example with the utility functionsavedag
, which unfortunately does not have an equivalent inGraphViz
's public API.Another thing to take care of is to make sure that unit tests can use functions internally defined in the extensions. This adds a few lines at the top of
loginfo_test.jl
, but it also provides a clean way to check whether extensions are actually loaded, so all in all I'm rather happy with this.So I guess the next questions are:
GraphViz
andMakie
as weak dependencies? The associated TODO list would IMO mostly involve adapting the documentation and examples to the new API (with a bit of a question mark related to howDocumenter
handles extensions)Requires
-based optional dependencies for users of julia v1.8 and below? It looks like this is feasible, but it would involve a few extra steps.DataFlowTasks
that would not be usable until extensions are loaded.