Skip to content

Commit

Permalink
update PAST node access pattern from Program instance (#423)
Browse files Browse the repository at this point in the history
* update PAST node access pattern from Program instance
* update gt4py-stable version
  • Loading branch information
edopao authored and iomaganaris committed Jun 18, 2024
1 parent fd23838 commit 3719d62
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions spack/gt4py-stable/spack.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
spack:
specs:
- py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.4%gcc@9.3.0
- py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.5%gcc@9.3.0
view: false
concretizer:
unify: true
develop:
py-icon4py:
spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.4%gcc@9.3.0
spec: py-icon4py@main%gcc@9.3.0 ^py-gt4py@1.0.3.5%gcc@9.3.0
path: ../../
16 changes: 9 additions & 7 deletions tools/src/icon4pytools/icon4pygen/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def _ignore_subscript(node: past.Expr) -> past.Name:
def _get_field_infos(fvprog: Program) -> dict[str, FieldInfo]:
"""Extract and format the in/out fields from a Program."""
assert all(
is_list_of_names(body.args) for body in fvprog.past_node.body
is_list_of_names(body.args) for body in fvprog.past_stage.past_node.body
), "Found unsupported expression in input arguments."
input_arg_ids = set(arg.id for body in fvprog.past_node.body for arg in body.args) # type: ignore[attr-defined] # Checked in the assert
input_arg_ids = set(arg.id for body in fvprog.past_stage.past_node.body for arg in body.args) # type: ignore[attr-defined] # Checked in the assert

out_args = (body.kwargs["out"] for body in fvprog.past_node.body)
out_args = (body.kwargs["out"] for body in fvprog.past_stage.past_node.body)
output_fields = []
for out_arg in out_args:
if isinstance(out_arg, past.TupleExpr):
Expand All @@ -112,7 +112,7 @@ def _get_field_infos(fvprog: Program) -> dict[str, FieldInfo]:
inp=(field_node.id in input_arg_ids),
out=(field_node.id in output_arg_ids),
)
for field_node in fvprog.past_node.params
for field_node in fvprog.past_stage.past_node.params
if field_node.id not in SPECIAL_DOMAIN_MARKERS
}

Expand All @@ -122,8 +122,8 @@ def _get_field_infos(fvprog: Program) -> dict[str, FieldInfo]:
def _get_domain_arg_ids(fvprog: Program) -> set[Optional[eve.concepts.SymbolRef]]:
"""Collect all argument names that are used within the 'domain' keyword argument."""
domain_arg_ids = []
if "domain" in fvprog.past_node.body[0].kwargs.keys():
domain_arg = fvprog.past_node.body[0].kwargs["domain"]
if "domain" in fvprog.past_stage.past_node.body[0].kwargs.keys():
domain_arg = fvprog.past_stage.past_node.body[0].kwargs["domain"]
assert isinstance(domain_arg, past.Dict)
for arg in domain_arg.values_:
for arg_elt in arg.elts:
Expand Down Expand Up @@ -207,7 +207,9 @@ def provide_neighbor_table(chain: str, is_global: bool) -> DummyConnectivity:

def scan_for_offsets(fvprog: Program) -> list[eve.concepts.SymbolRef]:
"""Scan PAST node for offsets and return a set of all offsets."""
all_types = fvprog.past_node.pre_walk_values().if_isinstance(past.Symbol).getattr("type")
all_types = (
fvprog.past_stage.past_node.pre_walk_values().if_isinstance(past.Symbol).getattr("type")
)
all_field_types = [
symbol_type for symbol_type in all_types if isinstance(symbol_type, ts.FieldType)
]
Expand Down
2 changes: 1 addition & 1 deletion tools/src/icon4pytools/py2fgen/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _get_gt4py_func_params(func: Program, type_hints: dict[str, str]) -> List[Fu
dimensions=parse_type_spec(p.type)[0],
py_type_hint=type_hints[p.id],
)
for p in func.past_node.params
for p in func.past_stage.past_node.params
]


Expand Down

0 comments on commit 3719d62

Please sign in to comment.