Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pickle local object if lambdas are used #79

Closed
lars-reimann opened this issue Apr 6, 2024 · 4 comments · Fixed by #80
Closed

Can't pickle local object if lambdas are used #79

lars-reimann opened this issue Apr 6, 2024 · 4 comments · Fixed by #80
Assignees
Labels
bug 🪲 Something isn't working released Included in a release

Comments

@lars-reimann
Copy link
Member

lars-reimann commented Apr 6, 2024

Describe the bug

Starting the runner on a pipeline that contains lambdas leads to the following logs:

2024-04-06 19:58:54.544 [info] Launching Pipeline (ab133d54-709c-4605-ae98-e1babcb10642): file:///c%3A/Users/Lars/OneDrive/Desktop/test/test.sdstest - myPipeline
2024-04-06 19:58:54.544 [info] Sending message to python server: {"type":"program","id":"ab133d54-709c-4605-ae98-e1babcb10642","data":{"code":{"test":{"gen_test":"# Imports ----------------------------------------------------------------------\r\n\r\nimport safeds_runner\r\nfrom safeds.data.tabular.containers import Row, Table\r\n\r\n# Pipelines --------------------------------------------------------------------\r\n\r\ndef myPipeline():\r\n    titanic = safeds_runner.memoized_call(\"safeds.data.tabular.containers.Table.from_csv_file\", Table.from_csv_file, ['C:/Users/Lars/OneDrive/Desktop/test/titanic.csv'], [safeds_runner.file_mtime('C:/Users/Lars/OneDrive/Desktop/test/titanic.csv')])\r\n    safeds_runner.save_placeholder('titanic', titanic)\r\n    filtered = safeds_runner.memoized_call(\"safeds.data.tabular.containers.Table.filter_rows\", Table.filter_rows, [titanic, lambda param1: (safeds_runner.memoized_call(\"safeds.data.tabular.containers.Row.get_value\", Row.get_value, [param1, 'age'], [])) >= (18)], [])\r\n    safeds_runner.save_placeholder('filtered', filtered)\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-06 19:58:54.545 [info] [Runner-Err] DEBUG:root:Received Message: {"type":"program","id":"ab133d54-709c-4605-ae98-e1babcb10642","data":{"code":{"test":{"gen_test":"# Imports ----------------------------------------------------------------------\r\n\r\nimport safeds_runner\r\nfrom safeds.data.tabular.containers import Row, Table\r\n\r\n# Pipelines --------------------------------------------------------------------\r\n\r\ndef myPipeline():\r\n    titanic = safeds_runner.memoized_call(\"safeds.data.tabular.containers.Table.from_csv_file\", Table.from_csv_file, ['C:/Users/Lars/OneDrive/Desktop/test/titanic.csv'], [safeds_runner.file_mtime('C:/Users/Lars/OneDrive/Desktop/test/titanic.csv')])\r\n    safeds_runner.save_placeholder('titanic', titanic)\r\n    filtered = safeds_runner.memoized_call(\"safeds.data.tabular.containers.Table.filter_rows\", Table.filter_rows, [titanic, lambda param1: (safeds_runner.memoized_call(\"safeds.data.tabular.containers.Row.get_value\", Row.get_value, [param1, 'age'], [])) >= (18)], [])\r\n    safeds_runner.save_placeholder('filtered', filtered)\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-06 19:58:57.204 [info] [Runner] Message received: '{"type": "placeholder_type", "id": "ab133d54-709c-4605-ae98-e1babcb10642", "data": {"name": "titanic", "type": "Table"}}'
2024-04-06 19:58:57.205 [info] Placeholder was calculated (ab133d54-709c-4605-ae98-e1babcb10642): titanic of type Table
2024-04-06 19:58:57.205 [info] Placeholder was calculated (ab133d54-709c-4605-ae98-e1babcb10642): titanic of type Table
2024-04-06 19:58:57.205 [info] Placeholder was calculated (ab133d54-709c-4605-ae98-e1babcb10642): titanic of type Table
2024-04-06 19:58:57.205 [info] Placeholder was calculated (ab133d54-709c-4605-ae98-e1babcb10642): titanic of type Table
2024-04-06 19:58:57.245 [info] [Runner] Message received: '{"type": "runtime_error", "id": "ab133d54-709c-4605-ae98-e1babcb10642", "data": {"message": "Can't pickle local object 'myPipeli<truncated>'

To Reproduce

Run the following pipeline:

package test

pipeline myPipeline {
    val titanic = Table.fromCsvFile("C:/Users/Lars/OneDrive/Desktop/test/titanic.csv");
    val filtered = titanic.filterRows((param1) -> (param1.getValue("age") as Int) >= 18);
}

Replace the path to the CSV file with some other one.

The same issue occurs with block lambdas:

package test

pipeline myPipeline {
    val titanic = Table.fromCsvFile("C:/Users/Lars/OneDrive/Desktop/test/titanic.csv");
    val filtered = titanic.filterRows((param1) {
        yield param2 = (param1.getValue("age") as Int) >= 18;
    });
}

Expected behavior

The pipeline should run without error.

Screenshots (optional)

No response

Additional Context (optional)

It would also be nice if errors would be marked with [error] instead of [info] in the logs.

@lars-reimann lars-reimann added the bug 🪲 Something isn't working label Apr 6, 2024
@lars-reimann lars-reimann self-assigned this Apr 8, 2024
@WinPlay02
Copy link
Contributor

@lars-reimann The lambda is already solved by the memoization PR I will submit later

@lars-reimann
Copy link
Member Author

lars-reimann commented Apr 8, 2024

OK, you can overwrite my change then (PR coming soon). I need it now for some final testing.

@lars-reimann lars-reimann linked a pull request Apr 8, 2024 that will close this issue
lars-reimann pushed a commit that referenced this issue Apr 9, 2024
## [0.8.1](v0.8.0...v0.8.1) (2024-04-09)

### Bug Fixes

* **deps:** bump pillow from 10.2.0 to 10.3.0 ([#77](#77)) ([32974d0](32974d0)), closes [#7928](https://github.com/Safe-DS/Runner/issues/7928) [#7912](https://github.com/Safe-DS/Runner/issues/7912) [#7883](https://github.com/Safe-DS/Runner/issues/7883) [#7925](https://github.com/Safe-DS/Runner/issues/7925) [#7920](https://github.com/Safe-DS/Runner/issues/7920) [#7818](https://github.com/Safe-DS/Runner/issues/7818) [#7918](https://github.com/Safe-DS/Runner/issues/7918) [#7658](https://github.com/Safe-DS/Runner/issues/7658) [#7209](https://github.com/Safe-DS/Runner/issues/7209) [#7884](https://github.com/Safe-DS/Runner/issues/7884) [#7888](https://github.com/Safe-DS/Runner/issues/7888) [#7894](https://github.com/Safe-DS/Runner/issues/7894) [#7900](https://github.com/Safe-DS/Runner/issues/7900) [#7891](https://github.com/Safe-DS/Runner/issues/7891) [#7893](https://github.com/Safe-DS/Runner/issues/7893) [#7882](https://github.com/Safe-DS/Runner/issues/7882) [#7870](https://github.com/Safe-DS/Runner/issues/7870) [#7872](https://github.com/Safe-DS/Runner/issues/7872) [#7881](https://github.com/Safe-DS/Runner/issues/7881) [#7880](https://github.com/Safe-DS/Runner/issues/7880) [#7644](https://github.com/Safe-DS/Runner/issues/7644) [#7753](https://github.com/Safe-DS/Runner/issues/7753) [#7706](https://github.com/Safe-DS/Runner/issues/7706) [#7791](https://github.com/Safe-DS/Runner/issues/7791) [#7788](https://github.com/Safe-DS/Runner/issues/7788) [#7823](https://github.com/Safe-DS/Runner/issues/7823) [#7840](https://github.com/Safe-DS/Runner/issues/7840) [#7842](https://github.com/Safe-DS/Runner/issues/7842) [#7821](https://github.com/Safe-DS/Runner/issues/7821) [#7797](https://github.com/Safe-DS/Runner/issues/7797) [#7798](https://github.com/Safe-DS/Runner/issues/7798) [#7713](https://github.com/Safe-DS/Runner/issues/7713) [#7827](https://github.com/Safe-DS/Runner/issues/7827) [#7838](https://github.com/Safe-DS/Runner/issues/7838) [#7843](https://github.com/Safe-DS/Runner/issues/7843) [#7852](https://github.com/Safe-DS/Runner/issues/7852) [#7855](https://github.com/Safe-DS/Runner/issues/7855) [#7849](https://github.com/Safe-DS/Runner/issues/7849) [#7709](https://github.com/Safe-DS/Runner/issues/7709) [#7779](https://github.com/Safe-DS/Runner/issues/7779) [#7841](https://github.com/Safe-DS/Runner/issues/7841) [#7782](https://github.com/Safe-DS/Runner/issues/7782) [#7804](https://github.com/Safe-DS/Runner/issues/7804) [#7810](https://github.com/Safe-DS/Runner/issues/7810) [#7744](https://github.com/Safe-DS/Runner/issues/7744) [#7928](https://github.com/Safe-DS/Runner/issues/7928) [#7927](https://github.com/Safe-DS/Runner/issues/7927) [#7883](https://github.com/Safe-DS/Runner/issues/7883) [#7818](https://github.com/Safe-DS/Runner/issues/7818) [#7918](https://github.com/Safe-DS/Runner/issues/7918) [#7920](https://github.com/Safe-DS/Runner/issues/7920) [#7658](https://github.com/Safe-DS/Runner/issues/7658) [#7209](https://github.com/Safe-DS/Runner/issues/7209) [#7884](https://github.com/Safe-DS/Runner/issues/7884) [#7888](https://github.com/Safe-DS/Runner/issues/7888) [#7894](https://github.com/Safe-DS/Runner/issues/7894) [#7900](https://github.com/Safe-DS/Runner/issues/7900) [#7891](https://github.com/Safe-DS/Runner/issues/7891) [#7893](https://github.com/Safe-DS/Runner/issues/7893) [#7882](https://github.com/Safe-DS/Runner/issues/7882) [#7870](https://github.com/Safe-DS/Runner/issues/7870) [#7872](https://github.com/Safe-DS/Runner/issues/7872) [#7928](https://github.com/Safe-DS/Runner/issues/7928) [#7927](https://github.com/Safe-DS/Runner/issues/7927)
* dynamic memoization calls ([#82](#82)) ([172b398](172b398))
* more robust hashing & pickling when memoizing ([#80](#80)) ([25c49e2](25c49e2)), closes [#75](#75) [#79](#79)
@lars-reimann
Copy link
Member Author

🎉 This issue has been resolved in version 0.8.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Apr 9, 2024
lars-reimann pushed a commit that referenced this issue Apr 9, 2024
## [0.9.0](v0.8.0...v0.9.0) (2024-04-09)

### Features

* dynamic memoization calls ([#82](#82)) ([9d31292](9d31292))

### Bug Fixes

* **deps:** bump pillow from 10.2.0 to 10.3.0 ([#77](#77)) ([32974d0](32974d0)), closes [#7928](https://github.com/Safe-DS/Runner/issues/7928) [#7912](https://github.com/Safe-DS/Runner/issues/7912) [#7883](https://github.com/Safe-DS/Runner/issues/7883) [#7925](https://github.com/Safe-DS/Runner/issues/7925) [#7920](https://github.com/Safe-DS/Runner/issues/7920) [#7818](https://github.com/Safe-DS/Runner/issues/7818) [#7918](https://github.com/Safe-DS/Runner/issues/7918) [#7658](https://github.com/Safe-DS/Runner/issues/7658) [#7209](https://github.com/Safe-DS/Runner/issues/7209) [#7884](https://github.com/Safe-DS/Runner/issues/7884) [#7888](https://github.com/Safe-DS/Runner/issues/7888) [#7894](https://github.com/Safe-DS/Runner/issues/7894) [#7900](https://github.com/Safe-DS/Runner/issues/7900) [#7891](https://github.com/Safe-DS/Runner/issues/7891) [#7893](https://github.com/Safe-DS/Runner/issues/7893) [#7882](https://github.com/Safe-DS/Runner/issues/7882) [#7870](https://github.com/Safe-DS/Runner/issues/7870) [#7872](https://github.com/Safe-DS/Runner/issues/7872) [#7881](https://github.com/Safe-DS/Runner/issues/7881) [#7880](https://github.com/Safe-DS/Runner/issues/7880) [#7644](https://github.com/Safe-DS/Runner/issues/7644) [#7753](https://github.com/Safe-DS/Runner/issues/7753) [#7706](https://github.com/Safe-DS/Runner/issues/7706) [#7791](https://github.com/Safe-DS/Runner/issues/7791) [#7788](https://github.com/Safe-DS/Runner/issues/7788) [#7823](https://github.com/Safe-DS/Runner/issues/7823) [#7840](https://github.com/Safe-DS/Runner/issues/7840) [#7842](https://github.com/Safe-DS/Runner/issues/7842) [#7821](https://github.com/Safe-DS/Runner/issues/7821) [#7797](https://github.com/Safe-DS/Runner/issues/7797) [#7798](https://github.com/Safe-DS/Runner/issues/7798) [#7713](https://github.com/Safe-DS/Runner/issues/7713) [#7827](https://github.com/Safe-DS/Runner/issues/7827) [#7838](https://github.com/Safe-DS/Runner/issues/7838) [#7843](https://github.com/Safe-DS/Runner/issues/7843) [#7852](https://github.com/Safe-DS/Runner/issues/7852) [#7855](https://github.com/Safe-DS/Runner/issues/7855) [#7849](https://github.com/Safe-DS/Runner/issues/7849) [#7709](https://github.com/Safe-DS/Runner/issues/7709) [#7779](https://github.com/Safe-DS/Runner/issues/7779) [#7841](https://github.com/Safe-DS/Runner/issues/7841) [#7782](https://github.com/Safe-DS/Runner/issues/7782) [#7804](https://github.com/Safe-DS/Runner/issues/7804) [#7810](https://github.com/Safe-DS/Runner/issues/7810) [#7744](https://github.com/Safe-DS/Runner/issues/7744) [#7928](https://github.com/Safe-DS/Runner/issues/7928) [#7927](https://github.com/Safe-DS/Runner/issues/7927) [#7883](https://github.com/Safe-DS/Runner/issues/7883) [#7818](https://github.com/Safe-DS/Runner/issues/7818) [#7918](https://github.com/Safe-DS/Runner/issues/7918) [#7920](https://github.com/Safe-DS/Runner/issues/7920) [#7658](https://github.com/Safe-DS/Runner/issues/7658) [#7209](https://github.com/Safe-DS/Runner/issues/7209) [#7884](https://github.com/Safe-DS/Runner/issues/7884) [#7888](https://github.com/Safe-DS/Runner/issues/7888) [#7894](https://github.com/Safe-DS/Runner/issues/7894) [#7900](https://github.com/Safe-DS/Runner/issues/7900) [#7891](https://github.com/Safe-DS/Runner/issues/7891) [#7893](https://github.com/Safe-DS/Runner/issues/7893) [#7882](https://github.com/Safe-DS/Runner/issues/7882) [#7870](https://github.com/Safe-DS/Runner/issues/7870) [#7872](https://github.com/Safe-DS/Runner/issues/7872) [#7928](https://github.com/Safe-DS/Runner/issues/7928) [#7927](https://github.com/Safe-DS/Runner/issues/7927)
* more robust hashing & pickling when memoizing ([#80](#80)) ([25c49e2](25c49e2)), closes [#75](#75) [#79](#79)
@lars-reimann
Copy link
Member Author

🎉 This issue has been resolved in version 0.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working released Included in a release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants