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

553 Adding files to Database when importing extrenal files #558

Conversation

LuukBlom
Copy link
Contributor

@LuukBlom LuukBlom commented Oct 14, 2024

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 call save_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 the IObject 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

@LuukBlom LuukBlom requested a review from panosatha October 14, 2024 13:24
@LuukBlom LuukBlom linked an issue Oct 14, 2024 that may be closed by this pull request
5 tasks
@panosatha panosatha changed the title 553 new development area shapefile not copied in projection folder 553 Adding files to Database when importing extrenal files Oct 15, 2024
@LuukBlom LuukBlom requested a review from panosatha October 15, 2024 14:56
Copy link
Contributor

@panosatha panosatha left a 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__
@LuukBlom LuukBlom requested a review from panosatha October 22, 2024 14:21
panosatha and others added 3 commits October 29, 2024 16:43
…tion-folder' of github.com:Deltares-research/FloodAdapt into 553-new-development-area-shapefile-not-copied-in-projection-folder
Copy link
Contributor

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

flood_adapt/dbs_classes/dbs_template.py Outdated Show resolved Hide resolved
@panosatha panosatha linked an issue Nov 18, 2024 that may be closed by this pull request
4 tasks
@LuukBlom
Copy link
Contributor Author

Incorporated in the hazard refactor: #473

@LuukBlom LuukBlom closed this Dec 18, 2024
@LuukBlom LuukBlom deleted the 553-new-development-area-shapefile-not-copied-in-projection-folder branch December 20, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants