8000 feat: install PyPI libraries for job tasks and give jobs API access by dmux · Pull Request #96 · dmux/minilake · GitHub
[go: up one dir, main page]

Skip to content

feat: install PyPI libraries for job tasks and give jobs API access - #96

Merged
dmux merged 1 commit into
mainfrom
feature/95-pypi-libraries-job-api-access
Nov 5, 2026
Merged

dmux merged 1 commit into
mainfrom
feature/95-pypi-libraries-job-api-access

Conversation

@dmux
@dmux dmux commented Nov 5, 2026
Copy link
Copy Markdown
Owner

Closes #95

Problem

Job tasks run in a sibling apache/spark container that only ships PySpark, so a script doing from databricks.sdk import WorkspaceClient fails with ModuleNotFoundError. libraries[].pypi was accepted but ignored, and the container had no way to call back into the API.

Changes

PyPI libraries

  • libraries[].pypi (package, optional repo) is honoured. Requirements are installed with pip install --target inside the job container, so the interpreter matches the one that runs the script, and put on PYTHONPATH before spark-submit.
  • The install is cached on the data volume per set of libraries (order-insensitive). It goes into a temporary directory and is renamed into place on success, so concurrent tasks cannot leave a half-written install.
  • Specs are validated: anything starting with - (a pip option) or an index URL that is not http(s) fails the task. Packages are passed after --.
  • A failed install fails the task with pip's output in the run logs.
  • MINILAKE_JOB_EXECUTOR=subprocess gets the same behaviour, installing for the python3 that runs the script.

API access from the job

  • Every task gets DATABRICKS_HOST and DATABRICKS_TOKEN, so WorkspaceClient() needs no arguments.
  • Host: MINILAKE_JOB_API_URL if set, otherwise minilake's own address on the network the job container joins (works on the default bridge too, no DNS needed), or http://127.0.0.1:<port> in subprocess mode. If it cannot be determined nothing is injected, rather than pointing the job at a localhost that is not minilake.
  • Token: MINILAKE_JOB_TOKEN, default dapi-minilake.
  • spark_env_vars still win.

The version is not bumped. The changelog entry is under [Unreleased].

Testing

  • Unit tests for validation, pip arguments, cache key, the container command, address discovery, env injection, and the subprocess path (including install reuse and failure), using a hand-built wheel so no network is needed.
  • Two API tests in tests/test_jobs.py: a pip-option-looking library fails the task, and databricks-sdk is installed from PyPI and WorkspaceClient() works inside a job.
  • Ran against the image built from this branch: tests/test_jobs.py, test_docker_executor.py, test_jobs_submit.py and test_app.py pass (79 passed, 2 skipped; the skipped ones need pip in the venv's python3 and pass with the system Python).
  • Checked end to end with a Docker-mode server: the first run installs the SDK (~15 s), the second reuses it (~6 s), and a run with no libraries still fails as before.
  • _own_container_address verified against real containers on the default bridge and on a user-defined network.

Notes

  • A job gets its host only when minilake is itself in Docker (or MINILAKE_JOB_API_URL is set). For a bare uv run minilake using the Docker executor, set MINILAKE_JOB_API_URL to an address the container can reach.
  • Installing needs network access to the package index from the job container.

- Honour libraries[].pypi: requirements are pip-installed with --target inside the
  job container, cached on the data volume per set of libraries, and put on
  PYTHONPATH. repo selects the index. Invalid specs fail the task.
- Inject DATABRICKS_HOST and DATABRICKS_TOKEN into every job so WorkspaceClient()
  works with no arguments. MINILAKE_JOB_API_URL / MINILAKE_JOB_TOKEN override them,
  and spark_env_vars take precedence.

Closes #95
@dmux dmux self-assigned this Nov 5, 2026
@dmux dmux added the enhancement New feature or request label Nov 5, 2026
@dmux
dmux merged commit 3a814a9 into main Nov 5, 2026
3 checks passed
@dmux
dmux deleted the feature/95-pypi-libraries-job-api-access branch November 5, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install PyPI libraries for job tasks and give jobs API access

1 participant

0