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

Model JSON format #232

Merged
merged 24 commits into from Nov 11, 2021
Merged

Model JSON format #232

merged 24 commits into from Nov 11, 2021

Conversation

dbhart
Copy link
Collaborator

@dbhart dbhart commented Oct 30, 2021

This PR adds full to_dict and from_dict functionality to the WaterNetworkModel. Additionally, this functionality is tested both using just dictionaries but also passing the dictionary in to and out of a JSON formatted file. Any format which can store a dictionary and then produce a dictionary when read in should also work (pickle, yaml, hdf5, etc.).

The to_dict() and write_json(f) functions are available on a WaterNetworkModel object.

The from_dict(d) and read_json(f) function is a class method on the WaterNetworkModel class and are aliased as standalone functions in the wntr.network module.

@coveralls
Copy link

coveralls commented Oct 30, 2021

Coverage Status

Coverage increased (+0.7%) to 84.052% when pulling 1d2dff4 on dbhart:json-model into 7d2d59a on USEPA:main.

@dbhart
Copy link
Collaborator Author

dbhart commented Nov 5, 2021

Additional changes: we have never used the SourceRegistry, so I removed it. I also removed the commented-out "to_string" function on the registries.

Copy link
Collaborator Author

@dbhart dbhart left a comment

Choose a reason for hiding this comment

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

@kaklise the code files we went over should be marked as "viewed". The documentation files should still pop up right away when you view the PR "Files changed". Assuming this works the way I think it should.

wntr/network/model.py Outdated Show resolved Hide resolved
@dbhart
Copy link
Collaborator Author

dbhart commented Nov 9, 2021 via email

@dbhart
Copy link
Collaborator Author

dbhart commented Nov 11, 2021

Created a wntr/network/io.py that now houses the main code for reading/creating/appending to/writing WaterNetworkModel files. The WaterNetworkModel class now calls the functions in this module instead of containing the code to do these IO operations.

@kaklise kaklise merged commit a898306 into USEPA:main Nov 11, 2021
@dbhart dbhart deleted the json-model branch June 23, 2023 14:52
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.

None yet

3 participants