Skip to content

Add public OneDep session metadata API#8

Draft
KingAlejandro wants to merge 2 commits into
developfrom
onedep-session-metadata-api
Draft

Add public OneDep session metadata API#8
KingAlejandro wants to merge 2 commits into
developfrom
onedep-session-metadata-api

Conversation

@KingAlejandro

Copy link
Copy Markdown

This PR is a small proposal for how DSP adapters could interact with OneDep Lib session storage without needing to know the details of the local session.json layout.

sequenceDiagram
    participant Adapter as DSP adapter
    participant OneDep as OneDep Lib
    participant Store as Local session store

    Adapter->>OneDep: list_session_metadata(base_dir)
    OneDep->>Store: read local sessions
    Store-->>OneDep: session summaries
    OneDep-->>Adapter: SessionSummary[]

    Adapter->>Adapter: user selects existing session or new session

    alt Resume existing session
        Adapter->>OneDep: deposit_resume(session_id, base_dir)
    else Create new session
        Adapter->>OneDep: deposit_init(..., base_dir)
    end

    OneDep-->>Adapter: Deposition
Loading

At first I started parsing the json session files, but I don't think that should be owned by the adapters necessarily, with these changes

  • OneDep Lib owns how sessions are stored and retrieved.
  • Adapters choose where sessions are stored, for example a project-local .onedep_sessions directory, this is what I am doing right now.
  • Adapters can list existing sessions and offer a resume/new-session choice to the user.
  • Adapters do not need to parse session.json directly.

@KingAlejandro KingAlejandro mentioned this pull request Jun 18, 2026
12 tasks
@KingAlejandro KingAlejandro requested a review from Copilot June 18, 2026 14:06
@KingAlejandro KingAlejandro marked this pull request as draft June 18, 2026 14:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a public API for retrieving local OneDep session metadata (and full session details) so DSP adapters can list/resume sessions without parsing session.json directly.

Changes:

  • Introduces SessionSummary and new facade functions: list_session_metadata(), get_session(), and get_session_metadata().
  • Adds a public base_dir parameter to deposit_init() / deposit_resume() to allow adapters to choose the session storage location.
  • Extends unit tests to cover the new entry points and base_dir usage.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/unit/test_deposition_facade.py Adds unit tests for base_dir resume and the new session metadata APIs.
src/onedep_lib/session/models.py Adds SessionSummary dataclass used for adapter-facing metadata.
src/onedep_lib/dsp.py Implements session summary helpers and new retrieval functions; adds base_dir support to init/resume.
src/onedep_lib/init.py Re-exports the new public session metadata APIs and SessionSummary.
Comments suppressed due to low confidence (2)

src/onedep_lib/dsp.py:124

  • Adding base_dir in the middle of the parameter list changes positional argument ordering for _base_dir, _api_client, and _check_runner, which can break downstream callers that passed those arguments positionally. To keep backward compatibility, keep the existing positional parameters unchanged and make base_dir a keyword-only argument at the end.
def deposit_init(
    email: str,
    users: list[str],
    country: Country,
    experiment_type: ExperimentType | None = None,
    em_subtype: EMSubType | None = None,
    coordinates: bool | None = None,
    config: DepositConfig | None = None,
    base_dir: Path | None = None,
    _base_dir: Path | None = None,
    _api_client: ApiClient | None = None,
    _check_runner: CheckRunnerProtocol | None = None,
) -> Deposition:

src/onedep_lib/dsp.py:175

  • Same positional-argument compatibility issue as deposit_init: inserting base_dir before _base_dir shifts the positional indices of the testing overrides and can break existing callers. Making base_dir keyword-only at the end preserves the previous positional signature.
def deposit_resume(
    session_id: str,
    config: DepositConfig | None = None,
    base_dir: Path | None = None,
    _base_dir: Path | None = None,
    _api_client: ApiClient | None = None,
    _check_runner: CheckRunnerProtocol | None = None,
) -> Deposition:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/onedep_lib/dsp.py
Comment thread src/onedep_lib/dsp.py
Comment on lines 193 to 196
config = config or DepositConfig.load()
base_dir = _base_dir or config.session_dir
store: SessionStore = JsonSessionStore(session_id, base_dir=base_dir)
session_base_dir = _session_base_dir(config, base_dir=base_dir, _base_dir=_base_dir)
store: SessionStore = JsonSessionStore(session_id, base_dir=session_base_dir)
store.get_session() # raises KeyError if not found

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi Alex, try the following after line 194 (session_base_dir = ...)

    if session_id not in (s.session_id for s, _ in list_sessions(base_dir=session_base_dir)):
        raise KeyError(f"Session with id {session_id} not found.")

@KingAlejandro KingAlejandro force-pushed the onedep-session-metadata-api branch from a8b1e6d to 7c051ca Compare June 18, 2026 20:22
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.

3 participants