Coder Social home page Coder Social logo

Comments (6)

alexjaffray avatar alexjaffray commented on July 18, 2024

@felixhorger yes, we only ever tested this from inside the GIRFReco environment, and didn't adjust the example after package-ization during the JOSS pre-review. I will adjust as per your final suggestion.

from girfreco.jl.

cncastillo avatar cncastillo commented on July 18, 2024

There are multiple ways of distributing the examples.

Option 1: Use the same environment as docs

In general, the documentation should have its own Project.toml. So to run the example it would be like this

julia --project=docs/ docs/lit/examples/joss_demo.jl

This is similar to what the CI does to generate the docs with GitHub actions. But really it should just work if I download it and run it.

Option 2: Use Literate to generate a Julia file that installs everything for you

In literate you can add special comments #jl (code that will be present only in the generated Julia file), #md (code that will only be in the generated docs), and #nb (for jupyter notebooks). So you can install the packages for the user in a temporary environment.

# This is text that will be present in the docs explaining the code
#jl using Pkg; Pkg.activate(; temp = true); Pkg.add("Package1"); Pkg.add("Package2")
using Package1, Pacakge2
im = recon(data)
p = plot_image(im)
#md savefig(p, "../assets/results.html") # hide
#jl display(p)
#md # ```@raw html
#md # <object type="text/html" data="../../assets/results.html"></object>
#md # ```

The link to the generated files can be added programmatically, see this as an example.

Option 3: Using Manifest.toml and Project.toml to set an environment for an specific example

If you really want a specific example to have a self-contained and reproducible environment you could add a Project.toml and Manifest.toml to docs/lit/examples/ (I think the Manifest.toml is enough). If you cd to that folder and open julia

(@v1.9) pkg> activate .
(@v1.9) pkg> instantiate
julia> include("joss_demo.jl")

But not sure how it will play with Literate if that environment is different from the one in docs (I would make my life easier and use the same environment).

Option 4: Use Pluto for self-contained environments

Another option is putting the example as a Pluto.jl notebook, this could be the best for reproducibility and ease of use because it contains its own Project.toml and Manifest.toml, can also be run as a normal Julia file and exported as plain HTML.

nb_path = "..."
s = Pluto.ServerSession();
nb = Pluto.SessionActions.open(s, nb_path; run_async=false)
html_contents = Pluto.generate_html(nb; binder_url_js="undefined")
open("test_pluto.html", "w") do io
    write(io, html_contents)
end

or opened like a notebook

using Pluto
Pluto.run() #Opens a tab in your browser that you could use to open the notebook

There could be more ways that I haven't thought but that is the jist of it.

from girfreco.jl.

alexjaffray avatar alexjaffray commented on July 18, 2024

#9 will be addressed here as well

from girfreco.jl.

alexjaffray avatar alexjaffray commented on July 18, 2024

#16

from girfreco.jl.

alexjaffray avatar alexjaffray commented on July 18, 2024

We have elected to pursue Option 1 for reducing the dependencies and also to streamline the running of the examples. This will achieve the target of a significantly more lightweight GIRFReco.jl. We will make this change and close this issue once completed.

from girfreco.jl.

alexjaffray avatar alexjaffray commented on July 18, 2024

We have implemented Option 1 into #4, and so are closing this.

from girfreco.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.