Safe-DS / Runner

Execute Safe-DS programs that were compiled to Python.
MIT License
2 stars 0 forks source link

Unhashable types #75

Closed lars-reimann closed 6 months ago

lars-reimann commented 6 months ago

Describe the bug

Trying to memoize unhashable values leads to errors. This includes, e.g. values of type dict. The memoized_call method should be more robust in this case.

To Reproduce

Example:

package test

pipeline myPipeline {
    val a = Table({
        "a": [1, 2, 3],
        "b": [4, 5, 6]
    });
}

Runner output:

2024-04-03 17:34:16.380 [info] Launching Pipeline (6b9aaa93-0ce7-444e-9c1e-839cb106ec80): file:///c%3A/Users/Lars/OneDrive/Desktop/test/test.sdstest - myPipeline
2024-04-03 17:34:16.380 [info] Sending message to python server: {"type":"program","id":"6b9aaa93-0ce7-444e-9c1e-839cb106ec80","data":{"code":{"test":{"gen_test":"# Imports ----------------------------------------------------------------------\r\n\r\nimport safeds_runner\r\nfrom safeds.data.tabular.containers import Table\r\n\r\n# Pipelines --------------------------------------------------------------------\r\n\r\ndef myPipeline():\r\n    a = safeds_runner.memoized_call(\"safeds.data.tabular.containers.Table\", lambda *_ : Table(data={'a': [1, 2, 3], 'b': [4, 5, 6]}), [{'a': [1, 2, 3], 'b': [4, 5, 6]}], [])\r\n    safeds_runner.save_placeholder('a', a)\r\n","gen_test_myPipeline":"from .gen_test import myPipeline\r\n\r\nif __name__ == '__main__':\r\n    myPipeline()\r\n"}},"main":{"modulepath":"test","module":"test","pipeline":"myPipeline"}}}
2024-04-03 17:34:16.381 [info] [Runner-Err] DEBUG:root:Received Message: {"type":"program","id":"6b9aaa93-0ce7-444e-9c1e-839cb106ec80","data":{"code":{"test":{"gen_test":"# Imports ----------------------------------------------------------------------\r\n\r\nimport safeds_runner\r\nfrom safeds.data.tabular.containers import Table\r\n\r\n# Pipelines --------------------------------------------------------------------\r\n\r\ndef myPipeline():\r\n    a = safeds_runner.memoized_call(\"safeds.data.tabular.containers.Table\", lambda *_ : Table(data={'a': [1, 2, 3], 'b': [4, 5, 6]}), [{'a': [1, 2, 3], 'b': [4, 5, 6]}], [])\r\n    safeds_runner.save_placeholder('a', a)\r\n","gen_test_myPipeline":"from .gen_test import myPipeline\r\n\r\nif __name__ == '__main__':\r\n    myPipeline()\r\n"}},"main":{"modulepath":"test","module":"test","pipeline":"myPipeline"}}}
2024-04-03 17:34:18.959 [info] [Runner] Message received: '{"type": "runtime_error", "id": "6b9aaa93-0ce7-444e-9c1e-839cb106ec80", "data": {"message": "unhashable type: 'dict'", "backtrac<truncated>'

Expected behavior

  1. Detect whether any values are unhashable and then do a normal function call without memoization.
  2. If possible, dict should be made hashable, since it might occur quite frequently.

Screenshots (optional)

No response

Additional Context (optional)

No response

lars-reimann commented 6 months ago

:tada: This issue has been resolved in version 0.8.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

lars-reimann commented 6 months ago

:tada: This issue has been resolved in version 0.9.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: