From a889ed8a02e7b71a7b35b597586c87fda071c9e7 Mon Sep 17 00:00:00 2001 From: Camilo De La Torre Date: Wed, 12 Feb 2025 23:27:27 +0100 Subject: [PATCH 1/3] make it precompile friendly --- test/Project.toml | 1 + test/priorityscheduler_test.jl | 2 +- test/staticscheduler_test.jl | 2 +- test/taskgraph_test.jl | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/Project.toml b/test/Project.toml index dc3f7977..749ee94e 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,5 +1,6 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +DataFlowTasks = "d1549cb6-e9f4-42f8-98cc-ffc8d067ff5b" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" diff --git a/test/priorityscheduler_test.jl b/test/priorityscheduler_test.jl index 53ed9a5c..7e9dc486 100644 --- a/test/priorityscheduler_test.jl +++ b/test/priorityscheduler_test.jl @@ -7,7 +7,7 @@ background = false sch = DataFlowTasks.PriorityScheduler(100, background) DataFlowTasks.setscheduler!(sch) -include(joinpath(DataFlowTasks.PROJECT_ROOT, "test", "testutils.jl")) +include(joinpath(DataFlowTasks._get_dataflowtasks_root(), "test", "testutils.jl")) @testset "Priority scheduler" begin @testset "Fork-join" begin diff --git a/test/staticscheduler_test.jl b/test/staticscheduler_test.jl index 3f797b08..0f9b1f0b 100644 --- a/test/staticscheduler_test.jl +++ b/test/staticscheduler_test.jl @@ -6,7 +6,7 @@ using LinearAlgebra sch = DataFlowTasks.StaticScheduler() DataFlowTasks.setscheduler!(sch) -include(joinpath(DataFlowTasks.PROJECT_ROOT, "test", "testutils.jl")) +include(joinpath(DataFlowTasks._get_dataflowtasks_root(), "test", "testutils.jl")) @testset "Static scheduler" begin @testset "Fork-join" begin diff --git a/test/taskgraph_test.jl b/test/taskgraph_test.jl index e9faa94b..13f2bff7 100644 --- a/test/taskgraph_test.jl +++ b/test/taskgraph_test.jl @@ -3,7 +3,7 @@ using LinearAlgebra using DataFlowTasks import DataFlowTasks as DFT -include(joinpath(DFT.PROJECT_ROOT, "test", "testutils.jl")) +include(joinpath(DFT._get_dataflowtasks_root(), "test", "testutils.jl")) tg = DFT.TaskGraph(200) DFT.set_active_taskgraph!(tg) From 101d7d2779625c5652408086a970c081c14e18cd Mon Sep 17 00:00:00 2001 From: Camilo De La Torre Date: Wed, 12 Feb 2025 23:30:54 +0100 Subject: [PATCH 2/3] make it precompile friendly --- docs/make.jl | 4 ++-- ext/DataFlowTasks_GraphViz_Ext.jl | 1 + ext/DataFlowTasks_Makie_Ext.jl | 1 + src/DataFlowTasks.jl | 25 ++++++++++++++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 985e0ff2..ebfdb3b4 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -28,7 +28,7 @@ end for example in ["cholesky", "blur-roberts", "lcs", "sort"] println("\n*** Generating $example example") @time begin - dir = joinpath(DataFlowTasks.PROJECT_ROOT, "docs", "src", "examples", example) + dir = joinpath(DataFlowTasks._get_dataflowtasks_root(), "docs", "src", "examples", example) src = joinpath(dir, "$(example).jl") Literate.markdown(src, dir) draft || Literate.notebook(src, dir; preprocess = insert_setup) @@ -37,7 +37,7 @@ end # generate readme println("\n*** Generating README") -@time cd(joinpath(DataFlowTasks.PROJECT_ROOT, "docs", "src", "readme")) do +@time cd(joinpath(DataFlowTasks._get_dataflowtasks_root(), "docs", "src", "readme")) do src = joinpath(pwd(), "README.jl") # Run code diff --git a/ext/DataFlowTasks_GraphViz_Ext.jl b/ext/DataFlowTasks_GraphViz_Ext.jl index 60d5c7e2..79e22859 100644 --- a/ext/DataFlowTasks_GraphViz_Ext.jl +++ b/ext/DataFlowTasks_GraphViz_Ext.jl @@ -1,3 +1,4 @@ +__precompile__() module DataFlowTasks_GraphViz_Ext using GraphViz diff --git a/ext/DataFlowTasks_Makie_Ext.jl b/ext/DataFlowTasks_Makie_Ext.jl index 97fbfee7..a2a08d3c 100644 --- a/ext/DataFlowTasks_Makie_Ext.jl +++ b/ext/DataFlowTasks_Makie_Ext.jl @@ -1,3 +1,4 @@ +__precompile__() module DataFlowTasks_Makie_Ext using Makie diff --git a/src/DataFlowTasks.jl b/src/DataFlowTasks.jl index 69eb4b16..20ba83a6 100644 --- a/src/DataFlowTasks.jl +++ b/src/DataFlowTasks.jl @@ -1,3 +1,5 @@ +__precompile__() + """ module DataFlowTask @@ -5,7 +7,7 @@ Create `Task`s which can keep track of how data flows through it. """ module DataFlowTasks -const PROJECT_ROOT = pkgdir(DataFlowTasks) +const PROJECT_ROOT::Ref{String} = Ref{String}() using OrderedCollections using Compat @@ -16,6 +18,19 @@ using Printf export @dspawn, @dasync + +""" + _get_dataflowtasks_root() + +Returns the current `PROJECT_ROOT` value. + +Does not assume the ref has been set. +""" +function _get_dataflowtasks_root() + global PROJECT_ROOT + return PROJECT_ROOT[] +end + """ @enum AccessMode READ WRITE READWRITE @@ -40,7 +55,15 @@ include("dag.jl") include("taskgraph.jl") include("arrayinterface.jl") +""" + __init__() + +Initializes the `PROJECT_ROOT` global constant to the `pkgdir` +of the module +""" function __init__() + global PROJECT_ROOT + PROJECT_ROOT[] = pkgdir(DataFlowTasks) # default scheduler capacity = 50 tg = TaskGraph(capacity) From e184bf335644193379e5a421088688834301f9d6 Mon Sep 17 00:00:00 2001 From: Camilo De La Torre Date: Thu, 13 Feb 2025 10:33:00 +0100 Subject: [PATCH 3/3] solving errors with julia 1.6.7 and 1.11 --- ext/DataFlowTasks_GraphViz_Ext.jl | 1 - ext/DataFlowTasks_Makie_Ext.jl | 1 - src/DataFlowTasks.jl | 12 ++++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ext/DataFlowTasks_GraphViz_Ext.jl b/ext/DataFlowTasks_GraphViz_Ext.jl index 79e22859..60d5c7e2 100644 --- a/ext/DataFlowTasks_GraphViz_Ext.jl +++ b/ext/DataFlowTasks_GraphViz_Ext.jl @@ -1,4 +1,3 @@ -__precompile__() module DataFlowTasks_GraphViz_Ext using GraphViz diff --git a/ext/DataFlowTasks_Makie_Ext.jl b/ext/DataFlowTasks_Makie_Ext.jl index a2a08d3c..97fbfee7 100644 --- a/ext/DataFlowTasks_Makie_Ext.jl +++ b/ext/DataFlowTasks_Makie_Ext.jl @@ -1,4 +1,3 @@ -__precompile__() module DataFlowTasks_Makie_Ext using Makie diff --git a/src/DataFlowTasks.jl b/src/DataFlowTasks.jl index 20ba83a6..8f151fa2 100644 --- a/src/DataFlowTasks.jl +++ b/src/DataFlowTasks.jl @@ -7,7 +7,12 @@ Create `Task`s which can keep track of how data flows through it. """ module DataFlowTasks -const PROJECT_ROOT::Ref{String} = Ref{String}() +dir = pkgdir(DataFlowTasks) +@static if VERSION > v"1.8" + const PROJECT_ROOT::Ref{String} = Ref{String}(dir) +else + const PROJECT_ROOT = Ref{String}(dir) +end using OrderedCollections using Compat @@ -18,7 +23,6 @@ using Printf export @dspawn, @dasync - """ _get_dataflowtasks_root() @@ -58,12 +62,8 @@ include("arrayinterface.jl") """ __init__() -Initializes the `PROJECT_ROOT` global constant to the `pkgdir` -of the module """ function __init__() - global PROJECT_ROOT - PROJECT_ROOT[] = pkgdir(DataFlowTasks) # default scheduler capacity = 50 tg = TaskGraph(capacity)