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

feat: support relative paths #83

Merged
merged 5 commits into from
Apr 10, 2024
Merged

feat: support relative paths #83

merged 5 commits into from
Apr 10, 2024

Conversation

lars-reimann
Copy link
Member

Closes #76

Summary of Changes

The cwd of the worker process can now be set via the new data.cwd item of the program message.

@lars-reimann lars-reimann requested a review from a team as a code owner April 10, 2024 09:51
@lars-reimann lars-reimann linked an issue Apr 10, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Apr 10, 2024

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 5 0 0 0.88s
✅ PYTHON mypy 5 0 2.65s
✅ PYTHON ruff 5 0 0 0.04s
✅ REPOSITORY git_diff yes no 0.01s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c32a4b6) to head (5dae678).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #83   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          522       530    +8     
=========================================
+ Hits           522       530    +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@WinPlay02 WinPlay02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is fine, just one conceptual question: How does this work with memoization?

Changing the cwd could lead to the same (relative) path resolving to different files.
As the timestamp is used to verify the valid re-usage of a file, this would probably not break correctness (and should be reasonably efficient, since the "older" files are not evicted from the cache (yet)), but it might cause confusion.

@lars-reimann
Copy link
Member Author

lars-reimann commented Apr 10, 2024

The code is fine, just one conceptual question: How does this work with memoization?

Changing the cwd could lead to the same (relative) path resolving to different files. As the timestamp is used to verify the valid re-usage of a file, this would probably not break correctness (and should be reasonably efficient, since the "older" files are not evicted from the cache (yet)), but it might cause confusion.

Could file_mtime return a tuple containing the absolute path of the file and the mtime? The function would need to be renamed, though (e.g. file_id).

@lars-reimann lars-reimann marked this pull request as draft April 10, 2024 10:55
@WinPlay02
Copy link
Contributor

Could file_mtime return a tuple containing the absolute path of the file and the mtime? The function would need to be renamed, though (e.g. file_id).

That should work, although reusing cached values between calls containing an absolute path and calls containing a relative path will not work.

@lars-reimann
Copy link
Member Author

lars-reimann commented Apr 10, 2024

Another idea would be changing the code generator to create

safeds_runner.memoized_static_call("...", Table.from_csv_file, [safeds_runner.path('titanic.csv')], [safeds_runner.file_mtime('titanic.csv')]

instead of

safeds_runner.memoized_static_call("..", Table.from_csv_file, ['titanic.csv'], [safeds_runner.file_mtime('titanic.csv')]

@WinPlay02
Copy link
Contributor

Another idea would be changing the code generator to create

safeds_runner.memoized_static_call("...", Table.from_csv_file, [safeds_runner.absolute_path('titanic.csv')], [safeds_runner.file_mtime('titanic.csv')]

instead of

safeds_runner.memoized_static_call("..", Table.from_csv_file, ['titanic.csv'], [safeds_runner.file_mtime('titanic.csv')]

The information about the parameters is available in the stubs via impurity information, so it could easily be added.
That would be the cleanest solution, as it shouldn't have any drawbacks.

@lars-reimann
Copy link
Member Author

I'll do that after lunch.

@lars-reimann lars-reimann marked this pull request as ready for review April 10, 2024 12:09
@WinPlay02 WinPlay02 merged commit a65261b into main Apr 10, 2024
8 checks passed
@WinPlay02 WinPlay02 deleted the 76-support-relative-paths branch April 10, 2024 13:10
lars-reimann pushed a commit that referenced this pull request Apr 10, 2024
## [0.10.0](v0.9.0...v0.10.0) (2024-04-10)

### Features

* support relative paths ([#83](#83)) ([a65261b](a65261b)), closes [#76](#76)
@lars-reimann
Copy link
Member Author

🎉 This PR is included in version 0.10.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
lars-reimann added a commit to Safe-DS/DSL that referenced this pull request Apr 10, 2024
### Summary of Changes

Use the runner functionality added in
Safe-DS/Runner#83 to support relative paths in
pipeline files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Included in a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support relative paths
3 participants