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

Jp/add code autogen #12

Merged
merged 10 commits into from
Jun 13, 2024
Merged

Jp/add code autogen #12

merged 10 commits into from
Jun 13, 2024

Conversation

jerrypotts
Copy link
Contributor

  • 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.

@jerrypotts jerrypotts requested a review from rodrigomha June 12, 2024 19:50
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"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

item["closing_constructor_text"] = " where T <: $(item["parametric"])"
end


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

accessor_name = accessor_module * "get_" * param["name"]
setter_name = accessor_module * "set_" * param["name"] * "!"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

# 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"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
item["needs_positional_constructor"] = item["has_internal"] && item["has_non_default_values"]
item["needs_positional_constructor"] =
item["has_internal"] && item["has_non_default_values"]


filename = joinpath(directory, item["struct_name"] * ".jl")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

open(filename, "w") do io
write(io, strip(Mustache.render(IS.STRUCT_TEMPLATE, item)))
write(io, "\n")
push!(struct_names, item["struct_name"])
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

if print_results
println("Wrote $filename")
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

@@ -144,6 +173,7 @@
println("Wrote $filename")
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

Copy link
Contributor

@rodrigomha rodrigomha left a 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

@jd-lara jd-lara merged commit a0238d1 into add_code_autogen Jun 13, 2024
1 of 5 checks passed
@jd-lara jd-lara deleted the jp/add_code_autogen branch June 13, 2024 21:06
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.

3 participants