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
Tooling for a make.jl file in the project root #315
Comments
This seems like it boils down to having a bunch of |
I'm not sure we're exactly on the same page :-) What I'm looking for is a way to automatically run the
where the The above snippet is currently in https://github.com/goerz-research/2022-01_Rydberg_Krotov_Spectral_Constraints, see also https://discourse.julialang.org/t/julia-based-makefile-replacement-for-research-workflows/74368/4?u=goerz That system could actually specifically handle the situation of running the same
under the assumption that the script takes the value for |
Okay, but that If the ScriptRule works we can add here via a PR, it fits to the package and doesn't bring any dependencies nor disturbs the workflow. What is a bit annoying is that you have to manually write down all files like |
Yeah, there’s no problem :-) The Discourse thread was just inquiring whether someone had already implemented a system like that (it seems not). This issue is to find out if there’s any interest in having make-like features built in to DrWatson (it seems like “maybe”). So what I’ll do is let my |
As for having to declare the output/target files: I agree, especially because it requires duplicating the call to |
The problem is that the output files generally depend on the arguments, so figuring out the output filenames requires running the code at some level. The only reasonable idea I've come up with would require
where The first output, P.S.: A small nitpick about the documentation. Maybe instead of
it would be clearer to have
I've gotten confused by |
I'd note that |
I was thinking of something much, much simpler. Julia has a folder watching functionality (that's how Revise.jl works actually). You can simply use the folder watching package, and tell it "watch these folders. Whenever a file is added in these folders, add its path and name to the X container". X will be a container that can be read by our make file business. Difficulties:
Perhaps we can kill two birds with one stone by adding this functionality to the macros Actually, this should work, and seems to be generic enough for your make idea? It also doesn't need folder watching functionality, the macros |
Please consider doing a pull request that fixes this, seems a rather straightforward documentation improvement! |
The X thingy can be a jld2 data file which can be read by a function |
Done in #318
Yeah, I don't think folder watching would even be required if you hook something into the existing macros
I'm not sure... it would have to record the command line arguments ( For clarity, let me just re-iterate what I'm trying to achieve: So, let's say I have a DrWatson-based project on Github, which I want people to be able to clone and reproduce. It contains scripts in the That's the part I'm trying to automate: Ideally, the person reproducing the project can simply run What you're proposing, I think, is to hook into I'd see two difficulties, though. The first is with recording the arguments ( The second problem is that I might want to play around with parameters and run scripts in the "exploratory" stage of the project, without wanting to record the result for the So it seems like it's possible, but not easier than having a I'd also say that |
Yes.
Well, that's kinda your problem. You chose to work with
no, just put the keyword
An overwhelming amount of options and keywords will swarm the ones that are truly useful, so we should be adding as much as possible only keywords that are genuinely useful. |
Fair enough. I don't think the idea of recording in some central database the output files each script produces is going to work for me, though. So I won't pursue that further. We'll have to agree to disagree with I'll figure out some way around this. What I might do is have a convention for my scripts that they (optionally) define a |
I must definitely have lost you somewhere, because you can always do, before calling the config = merge(config, ENV) Why, or how, is this a problem?
Okay, that's fine, but can you tell me why it won't work for your case though? Only then I can improve it. |
Well, as far as I'm concerned, there's nothing really to improve within DrWatson at this point. I thought it would help me to have a "dry-mode" in
Yes, I agree (or vice versa). We're definitely not on the same page about something, and I'm having a hard time figuring out what it is. As I said, I'm pretty happy at this point, so I'm not sure how much it matters, but let me try to explain.
Ok, now I'm super confused. The
Ok, so let's say I have three scripts in my project ./scripts/baseline.jl
./scripts/constrained_optimization_stage1.jl
./scripts/constrained_optimization_stage2.jl # reads the stage1 result and continues it I run these scripts five times as follows from the command line, in each case producing the output file indicated by the comment julia ./scripts/baseline.jl # -> ./data/out/result_iter_stop=100_ν_max=0.0GHz.jld2
julia ./scripts/constrained_optimization_stage1.jl 0.7GHz # -> ./data/out/result_iter_stop=100_ν_max=0.7GHz.jld2
julia ./scripts/constrained_optimization_stage1.jl 0.5GHz # -> ./data/out/result_iter_stop=100_ν_max=0.5GHz.jld2
julia ./scripts/constrained_optimization_stage2.jl 0.7GHz # -> ./data/out/result_iter_stop=1000_ν_max=0.7GHz.jld2
julia ./scripts/constrained_optimization_stage2.jl 0.5GHz # -> ./data/out/result_iter_stop=1000_ν_max=0.5GHz.jld2 To keep track of these calls, I record the script name and the command line It seemed to me what you were proposing is that There are still other problems with that approach, like the fact that I don't necessarily want to record every call to I think I must have misunderstood what you were proposing. In any case, just asking each script what output files it will produce for given Sorry for the long wall of text. I won't blame you for not going deeper on this, especially since there's no actual problem as far as I'm concerned 😀 |
Actually, there is one thing that would make the code in my script files a little bit cleaner: It would be nice to decouple produce_or_load(f::Function, outfile::AbstractString) (and similarly for the macro version). The above would simply call I'd rather want to write outfile = joinpath(outdir, savename(prefix, config, "jld2"))
@produce_or_load(outfile) do
result = do_something(config) # access `config` as a closure from outer scope
@strdict result
end than the current @produce_or_load(outdir, config, prefix=prefix) do config
result = do_something(config) # access `config` as function argument
@strdict result
end This is because I have to do Plus, while I think DrWatson's Anyway, this is a bit cosmetic, but if you think it would make a useful addition, in can probably prepare a PR for that particular new method of |
Let me think about this a bit more, though... I might open a separate issue |
So I don't think this will develop into something that will be closely tied to DrWatson. If I do ever put this functionality into a proper package, it might have some opinionated expectations on how scripts should be written, which you're probably not on board with. So let's close this |
As explained in https://discourse.julialang.org/t/julia-based-makefile-replacement-for-research-workflows/74368, it might be nice to have some tooling that would allow me to write a script
make.jl
in the root of my research project that would automatically run the scripts to generate any missing output files or plots.I realize this might a stretch, but it wouldn't seem entirely out-of-scope for a project like DrWatson to include something that takes a Dict defining a map of target files to dependencies and runs some code to produce those targets automatically.
The text was updated successfully, but these errors were encountered: