spcl / spcl/dace

Conserve python object in callbacks

Open
#1,188 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
593
Forks
163
Avg merge
2d 23h
Merged PRs (30d)
60

Description

_Issue_
Consider this code
```python
class MyObj_Is_An_Array:
def __init__():
self.a_data_to_access = 42
def __descriptor__(): # Give DaCe the possibility to use it as an array
...

# For the sake of the argument this function will _not_ be parsed by DaCe
# but triggers a callback
def callback(the_obj):
the_obj.a_data_to_access # <--- error, we get a dace.Array instead of a MyObj_Is_An_Array

@dace.program
def a_program(the_obj):
...
callback(the_obj)

the_obj = MyObj_Is_An_Array()
a_program(the_obj)
```

_Solution_
Marshall the true type of Python object in the callback system.

(Also we would need it to keep working with literal list, e.g. `callback([obj, obj, obj])`

_Motivation_

The [Pace code](https://github.com/NOAA-GFDL/pace) makes use of callback to access an optimized halo exchange system. Of course we should ultimately try and have the halo exchange be DaCe readable, but in the meantime callbacks are an effective (and used) way to reach working system in large codebase.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.