-
Notifications
You must be signed in to change notification settings - Fork 0
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
553 Adding files to Database when importing extrenal files #558
553 Adding files to Database when importing extrenal files #558
Conversation
… save any attached input files in the database
…d-in-projection-folder
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.
Look good, but the path used in the objects needs to be relative and not absolute to avoid issues with database transfer.
1. Made generic IObject/IObjectModel classes that all FloodAdapt Objects/ObjectModels should inherit from to reduce code duplication. 2. Implemented all save_additional functions + tests. 3. Added esolve_filepath() to resolve loading of external file attritbutes when they are set as a path vs a filename. 4. Cleanup: removed all occurences of storing a database path in an object. 5. Cleanup: moved all init code from functions like init_object_model and _init to the actual __init__
… the code to make all tests green
… a filename that is None
…tion-folder' of github.com:Deltares-research/FloodAdapt into 553-new-development-area-shapefile-not-copied-in-projection-folder
…d-in-projection-folder
…tion-folder' of github.com:Deltares-research/FloodAdapt into 553-new-development-area-shapefile-not-copied-in-projection-folder
…e can be duplicate names.
…ml, or that the user sets the cyc_file attribute to the path of their own .cyc file.
added .cyc file to test data
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.
editing a hurricane event does not seem to work. The object that is parsed to the save function does not have a reference to the cyc file
…d-in-projection-folder
Incorporated in the hazard refactor: #473 |
This PR implements the solution I had in mind for the hazard refactor already and some more.
It is a lot of files changed, but its mostly in importing and replacing.
I added an
IObjectModel
&IObject
class that every floodadapt object will inherit from containing the functions:load_file
load_dict
save
save_additional
where the first 3 are the same for all objects and already implemented in the base class.
save
will callsave_additional
first (to save any extra files to the database, then update the attrs before saving attrs to a toml file.save_additional
needs to be implemented for each subclass it is relevant and save the relevant files.__init__
needs to be implemented for each subclass as well as explained in theIObject
class.I implemented the above for all classes in the backend + tests.
I also added flood_adapt\object_model\interface\path_builder.py to be able to build filepaths inside the database.
The database and dbs_classes use this module to create paths.
Meaning, other modules can also construct paths using that module, without requiring access to the whole database object.
I also moved function (get_object_ids) to a separate module since fiat_model uses it, but also some measures. Not sure about where to put it, but this is already better imo. flood_adapt.object_model.direct_impact.measure.measure_helpers::get_object_ids
Should be merged together with: https://github.com/Deltares-research/FloodAdapt-GUI/pull/447