-
Notifications
You must be signed in to change notification settings - Fork 3
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
Jp/add code autogen #12
Conversation
jerrypotts
commented
Jun 12, 2024
- Updated generate_structs.jl to be compatible with the JSON Schema file for Sienna Invest.
- Generated new structs based on a JSON Schema file for the simple capacity expansion model we are using for initial development.
src/generate_structs.jl
Outdated
struct_names = Vector{String}() | ||
unique_accessor_functions = Set{String}() | ||
unique_setter_functions = Set{String}() | ||
|
||
for (struc_name, input) in data | ||
for (struct_name, input) in data.data["\$defs"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
src/generate_structs.jl
Outdated
item["closing_constructor_text"] = " where T <: $(item["parametric"])" | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
src/generate_structs.jl
Outdated
accessor_name = accessor_module * "get_" * param["name"] | ||
setter_name = accessor_module * "set_" * param["name"] * "!" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
src/generate_structs.jl
Outdated
# If all parameters have defaults then the positional constructor will | ||
# collide with the kwarg constructor. | ||
item["needs_positional_constructor"] = has_internal && has_non_default_values | ||
item["needs_positional_constructor"] = item["has_internal"] && item["has_non_default_values"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
item["needs_positional_constructor"] = item["has_internal"] && item["has_non_default_values"] | |
item["needs_positional_constructor"] = | |
item["has_internal"] && item["has_non_default_values"] |
src/generate_structs.jl
Outdated
|
||
filename = joinpath(directory, item["struct_name"] * ".jl") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
src/generate_structs.jl
Outdated
open(filename, "w") do io | ||
write(io, strip(Mustache.render(IS.STRUCT_TEMPLATE, item))) | ||
write(io, "\n") | ||
push!(struct_names, item["struct_name"]) | ||
end | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
src/generate_structs.jl
Outdated
if print_results | ||
println("Wrote $filename") | ||
end | ||
end | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
src/generate_structs.jl
Outdated
@@ -144,6 +173,7 @@ | |||
println("Wrote $filename") | |||
end | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good. Let's merge to Jose's branch.
What do you think @jd-lara