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

how to use dev:ed version of BestieTemplate.jl? #434

Open
lucaferranti opened this issue Sep 5, 2024 · 7 comments
Open

how to use dev:ed version of BestieTemplate.jl? #434

lucaferranti opened this issue Sep 5, 2024 · 7 comments
Labels
usage docs Related to documentation on how to use the package or template

Comments

@lucaferranti
Copy link
Contributor

lucaferranti commented Sep 5, 2024

Description

This is probably be missing something trivial, anyway

  1. I did ]dev BestieTemplate
  2. I did some changes in the questions under copier folder
  3. On a fresh Julia session, after using BestieTemplate; BestieTemplate.generate("Something.jl") it was still using the old version of the question, instead of my modified version. I also tried to manually force precompilation with Base.compilecache(Base.identify_package("BestieTemplate")) but it did not seem to help.

So my question is, after I ]dev BestieTemplate what is the recommended workflow to test changes I do in the yaml files and use the dev'ed version of the package?

@lucaferranti lucaferranti added the usage docs Related to documentation on how to use the package or template label Sep 5, 2024
@lucaferranti
Copy link
Contributor Author

without knowing any better about copier internals, I see a method

function generate(dst_path, data::Dict = Dict(); kwargs...)
  generate("https://github.com/abelsiqueira/BestieTemplate.jl", dst_path, data; kwargs...)
end

which hardcodes the source. I also noticed that despite I deved the package, it seems it is nevertheless using the latest release, because e.g. it has default indentation of 2.

Maybe copier uses the latest release from the repo by default?

@abelsiqueira
Copy link
Collaborator

There is another generate (being called by that one) that accepts the source path as argument. You can give the local path.
I also set up some dev debug tools: https://abelsiqueira.com/BestieTemplate.jl/dev/91-developer/#Testing-local-changes-to-the-template

@abelsiqueira
Copy link
Collaborator

Answering the other questions:

  • copier always uses a tag, if nothing is specified
  • Bestie by defaults uses the URL (to avoid having old versions locally)

@lucaferranti
Copy link
Contributor Author

how can I get the interactive questionnaire to work in debug mode?

I did a simple dummy change

diff --git a/copier/essential.yml b/copier/essential.yml
index 3be1880..021984d 100644
--- a/copier/essential.yml
+++ b/copier/essential.yml
@@ -37,7 +37,7 @@ JuliaMinVersion:
 
 License:
   type: str
-  help: Package license (You need an OSI license to register. You can suggest new licenses in the issues)
+  help: Package license  lalallalallal (You need an OSI license to register. You can suggest new licenses in the issues)
   choices:
     - Apache-2.0
     - GPL-3.0

then with the package deved I did the following

julia> using BestieTemplate;
    CondaPkg Found dependencies: /home/lferrant/.julia/environments/v1.10/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/packages/PythonCall/flx5V/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/dev/BestieTemplate/CondaPkg.toml
    CondaPkg Dependencies already up to date
    CondaPkg Found dependencies: /home/lferrant/.julia/environments/v1.10/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/packages/PythonCall/flx5V/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/dev/BestieTemplate/CondaPkg.toml
    CondaPkg Dependencies already up to date

julia> Dbg = BestieTemplate.Debug;

julia> Dbg.dbg_generate(data_choice=:ask)
/home/lferrant/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/vcs.py:201: DirtyLocalWarning: Dirty template changes included automatically.
  warn(

It did create a library PkgDebugBestie1 but it did not ask me anything interactively. It also prints a wanring about dirty template, which I'm not sure what it refers to. Note I did not cut the stacktrace at warn( that's everything that was printed.

@lucaferranti
Copy link
Contributor Author

Also, not sure if it's a bug or me misusing the command, but it seems that data_choice=:none throws atm

julia> Dbg.dbg_generate(data_choice=:none)
ERROR: Python: ValueError: Question "PackageOwner" is required
Python stacktrace:
 [1] _ask
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:502
 [2] run_copy
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:817
 [3] run_copy
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:1146
 [4] __exit__
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:228
 [5] run_copy
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:1145
Stacktrace:
  [1] pythrow()
    @ PythonCall.Core ~/.julia/packages/PythonCall/flx5V/src/Core/err.jl:92
  [2] errcheck
    @ ~/.julia/packages/PythonCall/flx5V/src/Core/err.jl:10 [inlined]
  [3] pycallargs(f::PythonCall.Core.Py, args::PythonCall.Core.Py, kwargs::PythonCall.Core.Py)
    @ PythonCall.Core ~/.julia/packages/PythonCall/flx5V/src/Core/builtins.jl:222
  [4] pycall(::PythonCall.Core.Py, ::String, ::Vararg{Any}; kwargs::@Kwargs{defaults::Bool, quiet::Bool, vcs_ref::String})
    @ PythonCall.Core ~/.julia/packages/PythonCall/flx5V/src/Core/builtins.jl:237
  [5] pycall
    @ ~/.julia/packages/PythonCall/flx5V/src/Core/builtins.jl:233 [inlined]
  [6] Py
    @ ~/.julia/packages/PythonCall/flx5V/src/Core/Py.jl:357 [inlined]
  [7] copy(src_path::String, dst_path::String, data::Dict{…}; kwargs::@Kwargs{})
    @ BestieTemplate.Copier ~/.julia/dev/BestieTemplate/src/Copier.jl:30
  [8] copy
    @ ~/.julia/dev/BestieTemplate/src/Copier.jl:28 [inlined]
  [9] _copy(src_path::String, dst_path::String, data::Dict{…}; kwargs::@Kwargs{})
    @ BestieTemplate ~/.julia/dev/BestieTemplate/src/api.jl:40
 [10] _copy
    @ ~/.julia/dev/BestieTemplate/src/api.jl:6 [inlined]
 [11] generate(src_path::String, dst_path::String, data::Dict{…}; kwargs::@Kwargs{})
    @ BestieTemplate ~/.julia/dev/BestieTemplate/src/api.jl:82
 [12] generate
    @ ~/.julia/dev/BestieTemplate/src/api.jl:75 [inlined]
 [13] dbg_generate(dst_path::String, _data::Dict{Any, Any}; data_choice::Symbol, kwargs::@Kwargs{})
    @ BestieTemplate.Debug ~/.julia/dev/BestieTemplate/src/debug/helper.jl:73
 [14] dbg_generate
    @ ~/.julia/dev/BestieTemplate/src/debug/helper.jl:66 [inlined]
 [15] top-level scope
    @ REPL[4]:1
 [16] top-level scope
    @ none:1

@abelsiqueira
Copy link
Collaborator

The dbg_ functions use defaults=true, which don't ask questions, which breaks with :none. The following works:

BestieTemplate.Debug.dbg_generate(data_choice=:none, defaults=false)
BestieTemplate.Debug.dbg_generate(defaults=false) # might be enough

I'm not committed to anything in the Debug section, so feel free to make suggestions.

@abelsiqueira
Copy link
Collaborator

The dirty warning comes from copier. It's dirty in the git sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usage docs Related to documentation on how to use the package or template
Projects
None yet
Development

No branches or pull requests

2 participants