Spawn worker in custom environment#1739
Conversation
|
@lhnwrk many thanks for your contribution to add the ability to run mlserver workers on different python versions. Internally mlserver communicates with these parallel workers using Having said that, the change you propose is slightly orthogonal to the above point as there is an argument to be made that we should set We suggest the following for us to be able to accept this change:
We can provide more pointers if you are happy to address the above. |
|
AFAIK we only need the worker process to have the same pickle protocol as the main process for I've updated the docs to point out the caveats for users, and extended the test suites to include custom environments with different python versions. For now they include the main process's python, the minimum tested python (3.9), and the maximum tested python (3.10) so we cover all cases of running a worker process with the same, lower, or higher python version. Let me know if there's anything else! |
| MIN_PYTHON_VERSION, | ||
| marks=pytest.mark.skipif( | ||
| MIN_PYTHON_VERSION >= PYTHON_VERSION, | ||
| reason="requires lower Python version", |
There was a problem hiding this comment.
I am not sure what does the reason mean here? for example if the current system python version is 3.8 then the parameter (3, 9) is not going to be used? and therefore the reason is probably misleading. Could you clarify please?
There was a problem hiding this comment.
My original thought was to test three cases of a worker environment with the same, lower, or higher Python version than the main process, so MIN_PYTHON_VERSION is only tested when it's lower than the main Python for example. This is updated now to just test all python versions between MIN_PYTHON_VERSION and MAX_PYTHON_VERSION.
| using pickled objects. Custom environments therefore **must** use the same | ||
| version of MLServer and a compatible version of Python with the same [default | ||
| pickle protocol](https://docs.python.org/3/library/pickle.html#pickle.DEFAULT_PROTOCOL) | ||
| as the main process. |
There was a problem hiding this comment.
could you also add a note about the specific python versions that are currently supported. i.e. a table showcasing main process and parallel workers python versions?
There was a problem hiding this comment.
Added a table here to clarify supported/tested worker environment!
| - conda-forge | ||
| dependencies: | ||
| - python == 3.8 | ||
| - python == 3.9 |
|
@lhnwrk could you rebase on top of master to make sure that tests are passing on this PR? |
|
@sakoush Rebased on |
| - scikit-learn == 1.0.2 | ||
| - pip: | ||
| - mlserver == 1.3.0.dev2 | ||
| - git+${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git@${GITHUB_REF} |
There was a problem hiding this comment.
I switched to installing mlserver from git here since worker environment has to match main process for this PR. GitHub Actions should set these environment variables to the fork/branch so the worker environment installs the same mlserver, but default to SeldonIO/MLServer's master branch in tox.ini otherwise.
There was a problem hiding this comment.
@lhnwrk is it possible to install from the local mlserver directory so it is easier logic and also locally we might want to be testing from changes done locally?
There was a problem hiding this comment.
I did go with this option first, but as it turns out this breaks docker build tests since the local mlserver directory is not available inside the container and the template Dockerfile only copies environment file. It has been a hassle to test locally though, what do you think if we use a separate yaml with a pinned version of mlserver for the CLI build test and install local directory for others?
| InferencePoolHook = Callable[[Worker], Awaitable[None]] | ||
|
|
||
|
|
||
| def _spawn_worker(settings: Settings, responses: Queue, env: Optional[Environment]): |
| - scikit-learn == 1.0.2 | ||
| - pip: | ||
| - mlserver == 1.3.0.dev2 | ||
| - git+${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git@${GITHUB_REF} |
There was a problem hiding this comment.
@lhnwrk is it possible to install from the local mlserver directory so it is easier logic and also locally we might want to be testing from changes done locally?
As per #1461, MLServer currently spawns worker with the same Python version as the main process, so user-provided environment is forced to match the Python version of the server. However,
multiprocessingallows setting the worker's executable path, this PR extends support for spawning workers in custom environments.