Publish harbor.models as a standalone `harbor-models` package

Open
#4,315 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
18/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with the open questions: read src/harbor/models and list what it imports from the rest of harbor, then check how packages/harbor-langsmith and packages/harbor-atif2otel consume harbor.models.job.result and harbor.models.job.plugin. The publishing side lives in scripts/publish.sh and the nightly workflow. Done means a packages/harbor-models member installable with only the five listed dependencies, with harbor.models.* imports still working and a test keeping any alias modules in sync. The author already has a branch, so the decision comes before the code.

Written by the indexing model from the issue text.

Description

Proposal: publish harbor.models as a standalone harbor-models package

Problem

The Pydantic models in harbor.models (task config, TrialResult, JobResult, JobConfig, ATIF trajectories, registry and package models) are Harbor's data contract. Other tools read and write them: result dashboards, training pipelines that consume rollouts, trajectory converters, and services that submit jobs to a Harbor runner.

Today the only way to get those models is pip install harbor, which pulls in the full CLI and runtime: litellm, supabase, fastapi, uvicorn, fastmcp, cryptography and more. For a consumer that only wants to parse a result.json or build a JobConfig, that is a heavy install and a source of version conflicts (see #3340 for litellm vs. openai>=3). Importing harbor.models.job.lock and harbor.models.dataset also loads other parts of harbor at import time.

The plugin packages in this repo already show the coupling: harbor-langsmith and harbor-atif2otel import harbor.models.job.result and harbor.models.job.plugin.

Proposal

Add a packages/harbor-models workspace member and publish it as harbor-models:

  • Contents: everything now under src/harbor/models, plus the small stdlib-only helpers it uses (the constants it needs, and the env, file_selection, path_safety and scripts utils).
  • Runtime dependencies: only pydantic, pyyaml, toml, shortuuid and pathspec.
  • Backward compatibility: every harbor.models.* import keeps working.
  • Import hygiene: the few model modules that reach into the runtime (Packager, skills, bridges and the registry client) import them lazily, so importing the models never loads the rest of harbor.

Users who install harbor see no change. Users who only need the schema can run pip install harbor-models without the CLI and its dependencies.

Open questions
  1. How should harbor-models be versioned? One option is lockstep: harbor pins harbor-models==<same version>, and the nightly workflow and scripts/publish.sh publish harbor-models first. The other is its own semver, so the models can stay stable while the CLI changes quickly.
  2. What import path should the package use?
    • Install into the harbor namespace as harbor.models. This keeps one import path with no alias modules. However, two distributions then write into harbor/, editable installs need harbor/__init__.py to extend __path__, and installing harbor-models alone leaves a partial harbor package.
    • Ship a separate top-level harbor_models package. This installs and imports cleanly without harbor. To keep harbor.models.* working, each module under src/harbor/models becomes an alias that replaces itself in sys.modules with the matching harbor_models module, so both names refer to the same module object. The aliases add one file per module, and a unit test would keep them in sync. If we go this way, should the aliases be permanent, or deprecated after a few releases in favour of harbor_models?
  3. Should the plugin packages (harbor-langsmith, harbor-atif2otel) switch to depending on harbor-models where they only need the types?

I have a branch that implements this and can open it as a PR if maintainers are open to the direction.

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.