Skip to content

Commit

Permalink
Merge branch 'main' into m-mohr-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr authored Dec 13, 2024
2 parents a82f82c + 9f72a9d commit 61d9a67
Show file tree
Hide file tree
Showing 21 changed files with 1,543 additions and 392 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
Expand Down
644 changes: 486 additions & 158 deletions examples/01_minibackend_demo.ipynb

Large diffs are not rendered by default.

37 changes: 20 additions & 17 deletions openeo_pg_parser_networkx/graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from __future__ import annotations

import sys

sys.setrecursionlimit(16385) # Necessary when parsing really big graphs
import functools
import json
import logging
Expand Down Expand Up @@ -110,7 +113,7 @@ def _parse_datamodel(nested_graph: dict) -> ProcessGraph:
Parses a nested process graph into the Pydantic datamodel for ProcessGraph.
"""

return ProcessGraph.parse_obj(nested_graph)
return ProcessGraph.model_validate(nested_graph, strict=True)

def _parse_process_graph(self, process_graph: ProcessGraph, arg_name: str = None):
"""
Expand Down Expand Up @@ -184,11 +187,11 @@ def _parse_argument(self, arg: any, arg_name: str, access_func: Callable):

# This access func business is necessary to let the program "remember" how to access and thus update this reference later
sub_access_func = partial(
lambda key, access_func, new_value=None, set_bool=False: access_func()[
key
]
if not set_bool
else access_func().__setitem__(key, new_value),
lambda key, access_func, new_value=None, set_bool=False: (
access_func()[key]
if not set_bool
else access_func().__setitem__(key, new_value)
),
key=k,
access_func=access_func,
)
Expand All @@ -202,11 +205,11 @@ def _parse_argument(self, arg: any, arg_name: str, access_func: Callable):
parsed_arg = parse_nested_parameter(element)

sub_access_func = partial(
lambda key, access_func, new_value=None, set_bool=False: access_func()[
key
]
if not set_bool
else access_func().__setitem__(key, new_value),
lambda key, access_func, new_value=None, set_bool=False: (
access_func()[key]
if not set_bool
else access_func().__setitem__(key, new_value)
),
key=i,
access_func=access_func,
)
Expand Down Expand Up @@ -243,12 +246,12 @@ def _walk_node(self):

# This just points to the resolved_kwarg itself!
access_func = partial(
lambda node_uid, arg_name, new_value=None, set_bool=False: self.G.nodes[
node_uid
]["resolved_kwargs"][arg_name]
if not set_bool
else self.G.nodes[node_uid]["resolved_kwargs"].__setitem__(
arg_name, new_value
lambda node_uid, arg_name, new_value=None, set_bool=False: (
self.G.nodes[node_uid]["resolved_kwargs"][arg_name]
if not set_bool
else self.G.nodes[node_uid]["resolved_kwargs"].__setitem__(
arg_name, new_value
)
),
node_uid=self._EVAL_ENV.node_uid,
arg_name=arg_name,
Expand Down
Loading

0 comments on commit 61d9a67

Please sign in to comment.