Skip to content

Commit

Permalink
Solo questing
Browse files Browse the repository at this point in the history
  • Loading branch information
JB Lovland committed Jan 19, 2024
1 parent 8bfd41c commit 1493b97
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 176 deletions.
1 change: 1 addition & 0 deletions boom.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def gen():
root_classes.add(Meta.model_validate(m).class_)
except Exception:
from pprint import pp

pp(m)
raise

Expand Down
6 changes: 5 additions & 1 deletion ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

print(sys.argv[1])
try:
Meta.model_validate_json(dumps(safe_load(open(sys.argv[1]))))
print(
Meta.model_validate_json(
dumps(safe_load(open(sys.argv[1])))
).fmu.realization.parameters
)
except Exception:
pp(safe_load(open(sys.argv[1])))
raise
38 changes: 38 additions & 0 deletions parameters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from __future__ import annotations

from typing import Dict, Union

from pydantic import RootModel


class Parameters(RootModel[Dict[str, Union[int, float, str, "Parameters"]]]):
...

# root: dict[str, int | float | str | Parameters]


# class Parameters(BaseModel):
# parameters: Union[int, float, str, "Parameters"]

# print(Parameters.model_rebuild())
# print(Parameters.model_json_schema())
print(
Parameters.model_validate({"hello": "hello", "this": {"this": "that", "more": 1}})
)
print(
Parameters.model_validate(
{
"SENSNAME": "faultseal",
"SENSCASE": "low",
"RMS_SEED": 1006,
"INIT_FILES": {
"PERM_FLUVCHAN_E1_NORM": 0.748433,
"PERM_FLUVCHAN_E21_NORM": 0.782068,
},
"KVKH_CHANNEL": 0.6,
"KVKH_US": 0.6,
"FAULT_SEAL_SCALING": 0.1,
"FWL_CENTRAL": 1677,
}
)
)
Loading

0 comments on commit 1493b97

Please sign in to comment.