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

switch to Configurations to support better @plugin macro and template serailization in TOML #254

Closed
wants to merge 25 commits into from

Conversation

Roger-luo
Copy link
Contributor

@Roger-luo Roger-luo commented Dec 4, 2020

This PR removes Parameters and use Configurations instead, since I think the goal of Configurations fits better for the PkgTemplate use case, and there is not much user interface change, all the old interfaces are the same including @plugin macro.

But you don't need to import @with_kw_noshow anymore, only use @plugin is sufficient since you can select your own code generators in Configurations. I think It makes the implementation of Plugin simpler and better and reduces the maintenance pressure of this package since I'm also going to help Pluto and Comonicon to switch to this configuration package - most of the code in Pluto, Comonicon's configuration structs and PkgTemplates' Plugin are actually similar. So I think this brings a much simpler implementation of Plugin.

A glance at some new features automatically (or by slightly overloading some interfaces of Configurations) enabled by using Configurations

Color, Compact, Copy Pastable Printing

I think currently it is a bit painful to read when all the fields are printed no matter it's just default value or not, now default values are automatically hidden and colors are used to help distinguish between kwargs, Plugin types and values. And you cannot copy pasta the printings back to REPL - this is also not convenient for sharing.

Before

image

After

image

Serialization to TOML files and potentially many other formats

now you can use Configurations.to_toml function to convert your templates to a TOML file easily. This makes sharing templates and modifying templates a lot easier and flexible. Also make things easier to read.

image

can you can read a template from a TOML file by Configurations.from_toml

image

since you can also convert a Template to OrderedDict using to_dict, it can be serialized to other format you like as well!

@codecov
Copy link

codecov bot commented Dec 4, 2020

Codecov Report

Merging #254 (ba7b252) into master (70ba6f7) will decrease coverage by 0.17%.
The diff coverage is 85.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #254      +/-   ##
==========================================
- Coverage   82.18%   82.01%   -0.18%     
==========================================
  Files          19       18       -1     
  Lines         612      606       -6     
==========================================
- Hits          503      497       -6     
  Misses        109      109              
Impacted Files Coverage Δ
src/PkgTemplates.jl 85.71% <ø> (ø)
src/plugins/badges.jl 50.00% <ø> (-16.67%) ⬇️
src/plugins/develop.jl 50.00% <ø> (-16.67%) ⬇️
src/plugins/src_dir.jl 83.33% <ø> (+3.33%) ⬆️
src/plugins/license.jl 86.66% <50.00%> (+5.71%) ⬆️
src/plugin.jl 77.77% <66.66%> (-6.10%) ⬇️
src/template.jl 88.31% <88.88%> (-2.24%) ⬇️
src/interactive.jl 74.35% <100.00%> (ø)
src/plugins/documenter.jl 69.84% <100.00%> (+4.62%) ⬆️
src/plugins/project_file.jl 63.63% <0.00%> (-6.37%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70ba6f7...ba7b252. Read the comment docs.

@Roger-luo
Copy link
Contributor Author

I'll add some more tests if people like this PR.

@christopher-dG
Copy link
Member

Holy cow, this is awesome. It'll take me a long time to review this but I definitely support the idea.

@Roger-luo
Copy link
Contributor Author

Roger-luo commented Dec 5, 2020

cool, I'll fix a few issues left first then:

  • do not expand homedir in serialized format or printings
  • fix 1.0 compatibility
  • add some tests for the serialization part

I think I can I assume the rest part should be covered by current test, but I could be wrong.

@Roger-luo
Copy link
Contributor Author

I realize we need to have JuliaLang/TOML.jl#13 fixed to be able to disable and use the default field of specified plugins. So don't merge this until that issue is fixed.

@Roger-luo
Copy link
Contributor Author

Roger-luo commented Dec 6, 2020

TBH I have no idea why the mock test errors in 1.0 (and it is extremely slow on 1.0), if you remove the mock, it seems to work fine, but with the mock, I got the following with a bus error locally. This is fine on other julia versions. I think this PR is ready to review now @christopher-dG .

I've fixed the TOML.jl issue above myself too (so I mark the test here as broken for now, and we could just change it back to @test when my PR is merged to TOML)

julia> mock(PT.version_of => _p -> v"1.2.3") do _i
                   with_pkg(t) do pkg
                       pkg_dir = abspath(expanduser(joinpath(t.dir, pkg)))
                       LibGit2.with(GitRepo(pkg_dir)) do repo
                           commit = GitCommit(repo, "HEAD")
                           @test occursin("PkgTemplates version: 1.2.3", LibGit2.message(commit))
                       end
                   end
               end
[ Info: Running prehooks
[ Info: Running hooks

@christopher-dG
Copy link
Member

Setting myself a reminder to review this weekend.

@christopher-dG
Copy link
Member

Sorry I've let this slip again. @nickrobinson251 any chance someone from Invenia would like to review? A big change in internals like this might be a good time for maintainership to pass over more formally to current Invenians.

@nickrobinson251
Copy link
Collaborator

@nickrobinson251 any chance someone from Invenia would like to review? A big change in internals like this might be a good time for maintainership to pass over more formally to current Invenians.

Sure! I'll bring it up this week to see who'd be interested :)

fyi @nick-thiessen and @omus

@nick-thiessen
Copy link

At the moment no one is free to review this, but in the next couple weeks someone might become available and possibly be available to take over maintainership. I'll have to have some conversations about who is interested.

@gdalle gdalle marked this pull request as draft December 19, 2023 09:06
@gdalle
Copy link
Collaborator

gdalle commented Dec 19, 2023

Currently trying to clean up the repo a little. Is this PR still relevant @Roger-luo?

@Roger-luo
Copy link
Contributor Author

Not anymore I've implemented this in rust

@gdalle
Copy link
Collaborator

gdalle commented Dec 20, 2023

My question was badly phrased, I was rather wondering whether it could be brought up to speed with the latest changes to the package?

@Roger-luo
Copy link
Contributor Author

I mean I don't even use this package anymore... I have no motivation to keep working on this PR, at least for myself, my own CLI tool is much easier to use than this package. https://discourse.julialang.org/t/ann-the-ion-command-line-for-julia-developers-written-in-rust/94495

@Roger-luo Roger-luo closed this Dec 21, 2023
@Roger-luo Roger-luo deleted the toml branch December 21, 2023 01:29
@gdalle
Copy link
Collaborator

gdalle commented Dec 21, 2023

Okay thanks. Still, I might revisit your ideas and try to switch to a better serialization at some point!

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

Successfully merging this pull request may close these issues.

5 participants