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

feat: Add meta properties for application specific console paths #165

Merged
merged 9 commits into from
Dec 22, 2023

Conversation

carloslubbers
Copy link
Contributor

This pr will allow the user to set env properties for console paths per application, overriding the default search paths of CONSOLE_FOLDER.

Setting for example DSTABILITY_CONSOLE_FOLDER to "C:\Program Files (x86)\Deltares\D-GEO Suite\D-Stability 2023.01\bin\D-Stability Console.exe" will let GEOLib use the system installed version of D-Stability without requiring a local copy in the CONSOLE_FOLDER

@MatthiasHauthDeltares
Copy link
Collaborator

I tried the following:

from pathlib import Path

from geolib import DStabilityModel

_path_stix = Path(r"C:\Users\hauth\.....\abc.stix")
model = DStabilityModel()
model.serialize(_path_stix)
print(model.custom_console_path)  # returns None
model.custom_console_path = r"C:\Program Files (x86)\Deltares\D-GEO Suite\D-Stability 2024.01\bin"  # Value error

It returns the error below. How can i manually set the console path?

Traceback (most recent call last):
File "C:\Users\hauth\bitbucket\GEOLib\tests\qwer.py", line 9, in
model.custom_console_path = r"C:\Program Files (x86)\Deltares\D-GEO Suite\D-Stability 2024.01\bin"
File "pydantic\main.py", line 357, in pydantic.main.BaseModel.setattr
ValueError: "DStabilityModel" object has no field "custom_console_path"

@carloslubbers
Copy link
Contributor Author

@MatthiasHauthDeltares The custom_console_path is an evaluated property so cannot be set directly, the value is retrieved from the meta properties (or from the geolib.env file) DSTABILITY_CONSOLE_PATH. Can you try setting that one?

@MatthiasHauthDeltares
Copy link
Collaborator

MatthiasHauthDeltares commented Dec 18, 2023

I don't quite get how you set a meta property. I only see a method get_meta_property but no setter. Also the model class no longer has a meta attribute

@carloslubbers
Copy link
Contributor Author

@MatthiasHauthDeltares Oops, the docs incorrectly specified there would be a meta property available on the model objects, I've added a set_meta_property for your convenience now:

from pathlib import Path

dm = DStabilityModel()
dm.set_meta_property("dstability_console_path", Path("C:/Program Files/......../DStabilityConsole.exe"))

Though note that meta properties are defined globally in your runtime and not per model, which is a bit ugly, so setting it on a model will change it for all models in your script

Carlos Lubbers added 2 commits December 18, 2023 17:57
# Conflicts:
#	geolib/models/dsettlement/dsettlement_model.py
@carloslubbers carloslubbers changed the title Add meta properties for application specific console paths feat: Add meta properties for application specific console paths Dec 20, 2023
Copy link

sonarcloud bot commented Dec 20, 2023

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@carloslubbers
Copy link
Contributor Author

This PR closes #149

@carloslubbers
Copy link
Contributor Author

This PR closes #164

@carloslubbers carloslubbers merged commit b478968 into master Dec 22, 2023
14 of 15 checks passed
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