Skip to content
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

Running examples #17

Closed
JulStraus opened this issue Mar 2, 2024 · 4 comments
Closed

Running examples #17

JulStraus opened this issue Mar 2, 2024 · 4 comments
Assignees

Comments

@JulStraus
Copy link
Member

The current change in the examples allow to run these from a version of EnergyModelsBase included from the registry through PR14. However, a problem now arises for testing the examples. In practice, the tests no longer utilize the version that is the latest, but instead the latest version from the Registry. When testing locally, this problem does not occur, but when testing on GitHub, that can become a problem.

Hence, we should find a solution with the following properties:

  • It still allows to run the examples directly from the file (including instantiation of the corresponding package) and
  • The tests are testing the latest version of the package.

Thoughts?

@hellemo
Copy link
Member

hellemo commented Jun 10, 2024

Two options that come to mind are:

  1. add Manifest.toml with a relative path reference to the parent folder
  2. develop the package if checked out for developmen or in CI, see Use dev version for examples when running tests #33 for an attempt to do this

@JulStraus
Copy link
Member Author

Point 1 would definitely work, although it would require minor changes in the .gitignore file.

Point 2 is a bit more interesting to check out. In practice, we cannot test whether it works except if we have it registered. Otherwise, we will never run in the potential problem that there is no possibility for overriding in a folder we do not have the right to override. I checked that out with a local version in which I called the functions for running the examples. In this situation, the problem was that is also used develop when calling it from a different environment as @__DIR__ = \EnergyModelsBase.jl\examples within the file.

@hellemo
Copy link
Member

hellemo commented Jun 11, 2024

When exactly do we want to run with the development version? I assume for CI and when we are running tests locally for new versions?

One alternative could be to use an explicit flag to turn this on, e.g. like

if haskey(ENV, "EMB_TEST_OR_CI")
    @info "only for test or CI"
end

and set the appropriate environment variable as part of the tests, but will not be run by default.

@JulStraus
Copy link
Member Author

After testing the directory of an added package, I think it can work:

julia> using EnergyModelsBase

julia> exdir = joinpath(pkgdir(EnergyModelsBase), "examples")
"\\.julia\\packages\\EnergyModelsBase\\XtYXL\\examples"

as it does not include the .jl ending, when added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants