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: python server #6

Merged
merged 50 commits into from
Nov 30, 2023
Merged

feat: python server #6

merged 50 commits into from
Nov 30, 2023

Conversation

WinPlay02
Copy link
Contributor

@WinPlay02 WinPlay02 commented Nov 6, 2023

  • every execution needs a unique id to identify calculated values
  • executes compiled safe-ds code in memory (using a finder / loader)
  • pipelines are executed in child processes
  • communication from child processes to the main process uses a shared memory queue
  • allows connections via websocket (and http)
  • listens on a provided port (default 5000)
  • uses flask and flask-sock for HTTP and WS
  • uses gevent as WSGI implementation

feat: accept websocket & http connections

test: added a partial test case for in memory execution

Co-authored-by: Jonas B <97200640+smitedeluxe@users.noreply.github.com>
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1cb1ba1) 100.00% compared to head (e949194) 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##              main        #6    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            2         6     +4     
  Lines           13       317   +304     
==========================================
+ Hits            13       317   +304     

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

Copy link

github-actions bot commented Nov 6, 2023

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 8 0 0 0.62s
✅ PYTHON mypy 8 0 1.7s
✅ PYTHON ruff 8 0 0 0.03s
✅ REPOSITORY git_diff yes no 0.02s

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

@WinPlay02
Copy link
Contributor Author

@lars-reimann Collecting coverage information across child processes (multiprocessing) does not seem to work.
I tried adding this section to .coveragerc:

[run]
parallel = True
concurrency = multiprocessing, thread

This also does not work, it only causes the testing process to freeze when calling multiprocessing.Manager() during setup.
Is there any (other) way to make coverage work with multiprocessing?

@lars-reimann
Copy link
Member

I have no experience with this. Maybe the pytest-cov documentation helps.

WinPlay02 and others added 5 commits November 28, 2023 00:20
…o python-server

# Conflicts:
#	tests/safeds_runner/server/test_websocket_mock.py
…ulation

misc: remove main function and flask specific entry points from coverage calculation
@WinPlay02
Copy link
Contributor Author

It seems to be a problem only on Windows, as the CI passes. I annotated the tests skip execution on Windows for now.
Although they work when coverage calculation does not include multiprocessing (in .coveragerc, see above).

src/safeds_runner/server/main.py Outdated Show resolved Hide resolved
src/safeds_runner/server/main.py Outdated Show resolved Hide resolved
src/safeds_runner/server/main.py Outdated Show resolved Hide resolved
src/safeds_runner/server/main.py Outdated Show resolved Hide resolved
src/safeds_runner/server/main.py Outdated Show resolved Hide resolved
src/safeds_runner/server/__init__.py Outdated Show resolved Hide resolved
src/safeds_runner/server/pipeline_manager.py Outdated Show resolved Hide resolved
tests/safeds_runner/server/test_websocket_mock.py Outdated Show resolved Hide resolved
tests/safeds_runner/server/test_websocket_mock.py Outdated Show resolved Hide resolved
@WinPlay02
Copy link
Contributor Author

I think I addressed all the suggestions. Now, the PipelineManager class takes the place of most of the global variables. It is created at startup and used in the websocket session.
But I couldn't get rid of the current_pipeline global in pipeline_manager.py as it is used for saving placeholders.

Copy link
Member

@lars-reimann lars-reimann left a comment

Choose a reason for hiding this comment

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

Looks great overall. I just have some minor requests.

src/safeds_runner/server/pipeline_manager.py Outdated Show resolved Hide resolved
src/safeds_runner/server/pipeline_manager.py Outdated Show resolved Hide resolved
src/safeds_runner/server/pipeline_manager.py Outdated Show resolved Hide resolved
Copy link
Member

@lars-reimann lars-reimann left a comment

Choose a reason for hiding this comment

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

Great contribution, thanks! 👍

@lars-reimann lars-reimann merged commit a2c4f0f into main Nov 30, 2023
8 checks passed
@lars-reimann lars-reimann deleted the python-server branch November 30, 2023 13:58
lars-reimann pushed a commit that referenced this pull request Nov 30, 2023
## [0.2.0](v0.1.0...v0.2.0) (2023-11-30)

### Features

* python server ([#6](#6)) ([a2c4f0f](a2c4f0f))
@lars-reimann
Copy link
Member

🎉 This PR is included in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Nov 30, 2023
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.

None yet

3 participants