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

Python generator inserts wrong file_mtime call #1012

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

Python generator inserts wrong file_mtime call #1012

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

Comments

@lars-reimann
Copy link
Member

Describe the bug

Running the code pasted below leads to the following error log:

2024-04-08 19:58:32.568 [info] Launching Pipeline (b886301b-34a2-47fe-8830-0366fa424c7d): file:///c%3A/Users/Lars/OneDrive/Desktop/test/test.sdstest - myPipeline
2024-04-08 19:58:32.568 [info] [Runner] Sending message to python server: {"type":"program","id":"b886301b-34a2-47fe-8830-0366fa424c7d","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    titanic = safeds_runner.memoized_call(\"safeds.data.tabular.containers.Table.remove_columns\", Table.remove_columns, [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')]), ['passenger_id', 'name', 'ticket', 'cabin', 'port_embarked']], [safeds_runner.file_mtime(['passenger_id', 'name', 'ticket', 'cabin', 'port_embarked'])])\r\n    safeds_runner.save_placeholder('titanic', titanic)\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-08 19:58:35.688 [info] [Runner] Message received: '{"type": "runtime_error", "id": "b886301b-34a2-47fe-8830-0366fa424c7d", "data": {"message": "argument should be a str or an os.P<truncated>'
2024-04-08 19:58:35.689 [error] [Runner] Runner-RuntimeError (b886301b-34a2-47fe-8830-0366fa424c7d): argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'list' 
	at E:\Repositories\safe-ds\Runner\src\safeds_runner\server\_pipeline_manager.py line 269
	at <frozen runpy> line 226
	at <frozen runpy> line 98
	at <frozen runpy> line 88
	at test/gen_test_myPipeline line 4
	at test/gen_test line 9 (mapped to 'test.sdstest' line 4)
	at E:\Repositories\safe-ds\Runner\src\safeds_runner\server\_pipeline_manager.py line 360
	at C:\Users\Lars\AppData\Local\Programs\Python\Python312\Lib\pathlib.py line 1162
	at C:\Users\Lars\AppData\Local\Programs\Python\Python312\Lib\pathlib.py line 373
2024-04-08 19:58:35.689 [error] [Runner] Safe-DS Error (b886301b-34a2-47fe-8830-0366fa424c7d): argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'list' 
	at file:///c%3A/Users/Lars/OneDrive/Desktop/test/test.sdstest#4 (c:\Users\Lars\OneDrive\Desktop\test\test.sdstest line 4)

It seems that the culprit is the incorrect call safeds_runner.file_mtime(['passenger_id', 'name', 'ticket', 'cabin', 'port_embarked']). It works fine if the chaining is replaced by an explicit assignment to a placeholder.

To Reproduce

Run the following code (replace the absolute path to the CSV file):

package test

pipeline myPipeline {
    val titanic = Table
        .fromCsvFile("C:/Users/Lars/OneDrive/Desktop/test/titanic.csv")
        .removeColumns(["passenger_id", "name", "ticket", "cabin", "port_embarked"]);
}

Expected behavior

No error.

Screenshots (optional)

No response

Additional Context (optional)

No response

@lars-reimann lars-reimann added the bug 🪲 Something isn't working label Apr 8, 2024
@lars-reimann
Copy link
Member Author

@WinPlay02 Do you have an idea what could cause this?

@WinPlay02
Copy link
Contributor

No, not directly. I'll try to investigate this issue and propose a fix

@lars-reimann
Copy link
Member Author

Thanks. It's not necessary to have this ready for this Friday, if you are otherwise occupied. We can tell people to "unchain" their calls for now.

@lars-reimann lars-reimann added this to the v0.11.0 milestone Apr 8, 2024
lars-reimann added a commit that referenced this issue Apr 9, 2024
…ropagating of impurity information across chained calls (#1015)

Closes #1012
closes #1013

### Summary of Changes

- fix generation of dynamic member function calls with memoization 
- fix propagating of impurity information across chained calls
- added a lot of tests to verify

The new `memoized_dynamic_call` is introduced + `memoized_static_call`
is used for global and static functions.
Calculating global / static function keys directly in the runner would
be a larger refactor and is not implemented here.
As there is no dynamic dispatch / inheritance for global / static
functions, this is not (as) important.

As a drive-by-fix, python calls on class members are now properly
memoized, including the instance the python call was declared on.

The code is also refactored to be a bit simpler, as the
`memoized_dynamic_call` function defers some of the responsibility to
the runner.

---------

Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
Co-authored-by: Lars Reimann <mail@larsreimann.com>
lars-reimann pushed a commit that referenced this issue Apr 10, 2024
## [0.11.0](v0.10.0...v0.11.0) (2024-04-10)

### Features

* add `toFloat` methods for `Int` and `String` ([#1018](#1018)) ([55a2050](55a2050))
* fine-grained control over inlay hints for parameter names ([#1016](#1016)) ([2667caf](2667caf))
* messaging service ([#1004](#1004)) ([dcf4ecf](dcf4ecf))
* semantic highlighting of block lambda results ([#1011](#1011)) ([228733c](228733c))
* start runner in language server ([#1006](#1006)) ([ef4bb6f](ef4bb6f))
* stubs for int conversions ([#1008](#1008)) ([b635f5a](b635f5a))
* support relative paths ([#1019](#1019)) ([3d3f28d](3d3f28d))
* trigger EDA tool via code lenses ([#1010](#1010)) ([eb6e4b6](eb6e4b6))

### Bug Fixes

* consumption of source maps ([#1005](#1005)) ([ea3da87](ea3da87))
* disable global EDA panel cache ([#1014](#1014)) ([f888027](f888027)), closes [/github.com//issues/986#issuecomment-2042731653](https://github.com/Safe-DS//github.com/Safe-DS/DSL/issues/986/issues/issuecomment-2042731653)
* generation of dynamic member function calls with memoization + propagating of impurity information across chained calls ([#1015](#1015)) ([19015c3](19015c3)), closes [#1012](#1012) [#1013](#1013)
* only spawn one runner process and shut it down properly ([#1009](#1009)) ([2c72cee](2c72cee))
* show EDA tool for `TaggedTable` and `TimeSeries` ([#1017](#1017)) ([ffae98a](ffae98a))
@lars-reimann
Copy link
Member Author

🎉 This issue has been resolved in version 0.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Apr 10, 2024
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
2 participants