I’ve written some bioinformatics analysis scripts in julia. They are fast and impressed everyone! Now I would like to share them with my collaborators. They act inside a pipeline that took many years to develop, and which assumes a certain file structure. something like
ScienceAnalysis1
|-data
|. |-img
|. |-raw
|. |-tmp
|-figures
|-scripts
I’m wondering what the best way to share my scripts are to minimize the stress for my non-julia colleagues.
I’ve been impressed by the slightly trivial but powerful here::here()
function in R . With here::here()
you give a non-programmer colleague your .Rmd file, and if you have an .Rproj file in science analysis, it knows where the files are and can walk those directories with basically no fiddling.
In julia I would love to be able to do the rough equivalent, but perhaps slightly more elevated code sharing. I envision the perfect sharing instructions
"
1.) ] activate ScienceAnalysis1,
2.) ] add MyPackageOnPrivateGithubWithLotsOfDeps
3.) julia>
using MyPackageOnPrivateGithubWithLotsOfDeps
generate_mindblowing_figures()"
"
But right now, in script form, it looks worse
0.) download and move my_script.jl to ScienceAnalysis1
1.) ] activate ScienceAnalysis1,
2.) ] add (all the dependencies)
3.) julia>
include(“path/to/ScienceAnalysis1/my script.jl”) (which makes heavy use of keyword variables that inherit global path-variables set by @__DIR__
)
generate_mindblowing_figures()
I could make a package, but then it’s not clear to me best practice on telling the package where the local directory or the project directory is.
I see the “experimental” Pkg.project
Would setting PROJECT_HOME = Pkg.project().path
at the top of the package module work? Does anyone have experience using Pkg.project().path
inside a module to tell a package where the “project home” is? Is this a bad idea?
Related questions, is it okay to have environment-dependent path keywords in the exported functions or is this breaking some kind of principle? maybe it should be a dynamic function PROJECT_HOME() = Pkg.project().path
?
Another almost perfect option is to set a global variable inside the module MyPackageOnPrivateGithubWithLotsOfDeps.PROJECT_HOME = Pkg.project().path
It’s just an extra step.
I appreciate expert thoughts on this, which is preferred and why?