Skip to content

feat(scripts): replace SepalClient with pysepal-api shim#992

Open
dfguerrerom wants to merge 3 commits into
mainfrom
feat/pysepal-api-shim
Open

feat(scripts): replace SepalClient with pysepal-api shim#992
dfguerrerom wants to merge 3 commits into
mainfrom
feat/pysepal-api-shim

Conversation

@dfguerrerom
Copy link
Copy Markdown
Collaborator

Summary

Replaces the in-tree pysepal.scripts.sepal_client.SepalClient with a thin shim that re-exports pysepal_api.compat.SepalClient from the new pysepal-api package (v0.1.0). The compat class is a byte-for-byte drop-in for the legacy class: same positional constructor, same legacy methods (list_files, get_file, set_file, get_remote_dir, sanitize_path), same public attributes (cookies dict, headers, BASE_REMOTE_PATH, results_path, module_name, base_url, verify_ssl), and a DeprecationWarning at construction time pointing callers at pysepal_api.SepalClient for new code.

Motivation

The new SEPAL sandbox API key (openforis/sepal@6a1c2022) lets code inside a sandbox authenticate to SEPAL services without browser cookies. That unlocks non-Solara contexts (Jupyter notebooks, Voila apps, CLI scripts, background jobs) that pysepal's UI-bound SepalClient couldn't serve. The new pysepal-api package owns the HTTP layer (user-files, tasks, processing-recipes) with sync + async clients, while pysepal remains the UI library. This PR is the integration step: pysepal depends on pysepal-api and the existing SepalClient import path keeps working unchanged.

Changes

  • pyproject.toml — add pysepal-api>=0.1.0.dev0,<1 to runtime dependencies (PEP 440 pin admits the dev pre-release that's currently published locally).
  • pysepal/scripts/sepal_client.py — replaced 208-line implementation with a 14-line shim re-exporting pysepal_api.compat.SepalClient.
  • pysepal/solara/session_manager.pycleanup_session() now calls sepal_client.close() on kernel teardown so the new persistent httpx.Client connection pool is released cleanly.
  • noxfile.py — added _preinstall_pysepal_api() helper that builds a wheel from a ../pysepal-api sibling repo (if present) and installs it before .[test], so the test sessions can resolve pysepal-api before it's on PyPI. No-op once published.

Removal timeline

The shim and compat surface stay until pysepal v4. Callers are encouraged to migrate to from pysepal_api import SepalClient for the modern API.

Test plan

  • nox -s test349 passed, 1 skipped locally (no regressions vs. main)
  • from pysepal.scripts.sepal_client import SepalClient; SepalClient.__module__ == "pysepal_api.compat"
  • Constructing SepalClient(session_id, module_name, sepal_host=...) emits DeprecationWarning and preserves all legacy attributes
  • CI on this PR (pysepal-api wheel will need to be available — see local-wheel preinstall in noxfile.py)
  • Sanity check from a real SEPAL sandbox (notebook): from pysepal_api import SepalClient; with SepalClient() as s: s.user_files.list("/")

Coordinated work

  • pysepal-api v0.1.0 is tagged locally but not yet pushed to a GitHub repo or PyPI. This PR depends on it being published before CI can resolve the dependency.

pysepal.scripts.sepal_client now re-exports pysepal_api.compat.SepalClient.
Existing call sites (FileInput, export_engine, SessionManager, notebooks)
keep working unchanged; the new class emits a DeprecationWarning at
construction time pointing at pysepal_api.SepalClient as the long-term
import path. The shim is scheduled for removal in pysepal v4.

Also tighten the pysepal-api version pin to >=0.1.0.dev0,<1 so the dev
pre-release wheel (not yet on PyPI) satisfies the constraint, and update
noxfile.py to pre-install the local sibling-repo wheel before the main
.[test] install so CI can resolve the dependency without PyPI access.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant