refactor: rename the application package to docsgpt

The backend import package is now docsgpt, the name it will carry on PyPI;
application was far too generic to install into anyone's site-packages.
git mv plus a mechanical rewrite of every import, dotted string and path
reference: 734 Python files, the compose files, Dockerfile, workflows, docs,
setup scripts, devcontainer, k8s manifests, vscode config, pytest and coverage
config, .gitignore. Behaviour is unchanged.

Kept for one release:
- A top-level application package whose meta-path finder resolves
  application.x.y to the already-imported docsgpt.x.y object, so old imports
  and entry points (celery -A application.app.celery,
  uvicorn application.asgi:asgi_app) keep working with a FutureWarning.
- Celery registers every application.* task name as an alias of its
  docsgpt.* task on start-up, so messages queued by the previous release still
  run. The redbeat key prefix moves to redbeat:docsgpt:v2: so schedule entries
  the previous release wrote are left unread instead of firing twice.

The backend image builds from the repository root (docker build -f
docsgpt/Dockerfile .) so it can ship the alias package; a root .dockerignore
allow-lists docsgpt/ and application/ and keeps caches, local data, .env
files, the sample index files and the Dockerfile out. Compose and the image
workflows point at the new context.
This commit is contained in:
Alex committed 2026-09-07 10:20:43 +01:00
1 parent 3e7f1f91b4
commit 574f96341e
984 files changed
+9847 -9682

No files matched your search

+3 -3
View File
@@ -20,13 +20,13 @@ import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
from scripts import grant_admin # noqa: E402
from application.storage.db.repositories.auth_events import ( # noqa: E402
from docsgpt.storage.db.repositories.auth_events import ( # noqa: E402
AuthEventsRepository,
)
from application.storage.db.repositories.user_roles import ( # noqa: E402
from docsgpt.storage.db.repositories.user_roles import ( # noqa: E402
UserRolesRepository,
)
from application.storage.db.repositories.users import UsersRepository # noqa: E402
from docsgpt.storage.db.repositories.users import UsersRepository # noqa: E402
@pytest.fixture
+2 -2
View File
@@ -6,8 +6,8 @@ from unittest.mock import MagicMock, patch
import pytest
from application.scripts import prefetch_models
from application.vectorstore.model_registry import GRANITE_311M, MPNET, OPENAI_ADA_002
from docsgpt.scripts import prefetch_models
from docsgpt.vectorstore.model_registry import GRANITE_311M, MPNET, OPENAI_ADA_002
@pytest.fixture
+9 -9
View File
@@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
import pytest
from application.scripts import reembed
from docsgpt.scripts import reembed
def paginating_cursor(chunk_rows, *, graph_rows=(), graph_table=("graph_nodes",)):
@@ -323,7 +323,7 @@ class TestFaissSourceDiscovery:
"indexes/src-b/index.faiss",
]
with patch(
"application.storage.storage_creator.StorageCreator.get_storage",
"docsgpt.storage.storage_creator.StorageCreator.get_storage",
return_value=storage,
):
assert reembed.list_source_ids("faiss") == ["src-a", "src-b"]
@@ -332,7 +332,7 @@ class TestFaissSourceDiscovery:
storage = MagicMock()
storage.list_files.side_effect = OSError("permission denied")
with patch(
"application.storage.storage_creator.StorageCreator.get_storage",
"docsgpt.storage.storage_creator.StorageCreator.get_storage",
return_value=storage,
):
with pytest.raises(reembed.ReembedError, match="permission denied"):
@@ -453,7 +453,7 @@ class TestEmbedsInProcess:
"""A batch job should not round-trip every chunk through the broker."""
def test_delegation_is_turned_off_for_the_run(self, monkeypatch):
from application.core.settings import settings
from docsgpt.core.settings import settings
monkeypatch.setattr(settings, "EMBEDDINGS_DELEGATE_TO_WORKER", True, raising=False)
monkeypatch.setattr(settings, "VECTOR_STORE", "pgvector", raising=False)
@@ -469,14 +469,14 @@ class TestRecordsTheModel:
"""``sources.model`` is what the boot mismatch check reads."""
def test_a_re_embedded_source_is_stamped(self, monkeypatch):
from application.core.settings import settings
from docsgpt.core.settings import settings
monkeypatch.setattr(settings, "EMBEDDINGS_NAME", "new/model", raising=False)
conn = MagicMock()
session = MagicMock()
session.__enter__ = MagicMock(return_value=conn)
session.__exit__ = MagicMock(return_value=False)
with patch("application.storage.db.session.db_session", return_value=session):
with patch("docsgpt.storage.db.session.db_session", return_value=session):
reembed.record_source_model("src-1")
params = conn.execute.call_args.args[1]
assert params == {"model": "new/model", "id": "src-1"}
@@ -506,7 +506,7 @@ class TestRecordsTheModel:
class TestThePinIsResolved:
"""The script must embed with the model the installation is pinned to.
``resolve_embeddings_pin`` runs in ``application.app``, which this script
``resolve_embeddings_pin`` runs in ``docsgpt.app``, which this script
never imports. An install pinned in ``app_metadata`` with no
``EMBEDDINGS_NAME`` in the environment -- every stock Kubernetes
deployment, whose manifests carry no embedding config -- would otherwise
@@ -518,7 +518,7 @@ class TestThePinIsResolved:
def test_main_resolves_the_pin_before_reading_the_store(self):
order = []
with patch(
"application.storage.db.embeddings_pin.resolve_embeddings_pin",
"docsgpt.storage.db.embeddings_pin.resolve_embeddings_pin",
side_effect=lambda *a, **k: order.append("pin"),
), patch.object(reembed.settings, "VECTOR_STORE", "pgvector", create=True), patch.object(
reembed, "run", side_effect=lambda *a, **k: (order.append("run"), 0)[1]
@@ -528,7 +528,7 @@ class TestThePinIsResolved:
def test_an_unsupported_store_still_resolved_the_pin_first(self):
with patch(
"application.storage.db.embeddings_pin.resolve_embeddings_pin"
"docsgpt.storage.db.embeddings_pin.resolve_embeddings_pin"
) as pin, patch.object(reembed.settings, "VECTOR_STORE", "qdrant", create=True):
assert reembed.main([]) == 2
pin.assert_called_once()
+16 -16
View File
@@ -11,9 +11,9 @@ from unittest.mock import patch
import pytest
from application.scripts import reembed
from application.vectorstore import pgvector as pgvector_module
from application.vectorstore.pgvector import PGVectorStore
from docsgpt.scripts import reembed
from docsgpt.vectorstore import pgvector as pgvector_module
from docsgpt.vectorstore.pgvector import PGVectorStore
pytestmark = pytest.mark.integration
@@ -68,7 +68,7 @@ def live_dsn(postgresql, monkeypatch):
pytest.skip(f"pgvector extension unavailable: {exc}")
dsn = _dsn(postgresql.info)
from application.core import settings as settings_module
from docsgpt.core import settings as settings_module
settings = settings_module.settings
monkeypatch.setattr(settings, "VECTOR_STORE", "pgvector", raising=False)
@@ -83,7 +83,7 @@ def live_dsn(postgresql, monkeypatch):
def _seed(dsn, source_id, texts, embeddings):
"""Create the schema and insert ``texts`` embedded by ``embeddings``."""
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=embeddings,
):
store = PGVectorStore(source_id=source_id, connection_string=dsn)
@@ -139,7 +139,7 @@ class TestReembedPgvectorLive:
new_model = _Embeddings(9.0)
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=new_model,
):
seen, written = reembed.reembed_pgvector("src-a", batch_size=2, dry_run=False)
@@ -154,7 +154,7 @@ class TestReembedPgvectorLive:
_seed(live_dsn, "src-b", TEXTS, _Embeddings(1.0))
new_model = _Embeddings(9.0)
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=new_model,
):
seen, written = reembed.reembed_pgvector("src-b", batch_size=2, dry_run=True)
@@ -167,7 +167,7 @@ class TestReembedPgvectorLive:
_seed(live_dsn, "src-c", TEXTS, _Embeddings(1.0))
new_model = _Embeddings(9.0)
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=new_model,
):
reembed.reembed_pgvector("src-c", batch_size=2, dry_run=False)
@@ -177,7 +177,7 @@ class TestReembedPgvectorLive:
_seed(live_dsn, "src-d", TEXTS, _Embeddings(1.0))
_seed(live_dsn, "src-e", TEXTS, _Embeddings(1.0))
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=_Embeddings(9.0),
):
reembed.reembed_pgvector("src-d", batch_size=64, dry_run=False)
@@ -196,7 +196,7 @@ GRAPH_SOURCE = "11111111-2222-3333-4444-555555555555"
def _seed_graph_node(dsn, source_id, name, seed):
"""Insert one graph node carrying a name embedding at ``seed``."""
from application.graphrag.store import GraphStore
from docsgpt.graphrag.store import GraphStore
store = PGVectorStore(source_id=source_id, connection_string=dsn)
conn = store._get_connection()
@@ -240,7 +240,7 @@ class TestGraphNodeReembedLive:
"""
def test_node_names_are_re_embedded(self, live_dsn, monkeypatch):
from application.core import settings as settings_module
from docsgpt.core import settings as settings_module
monkeypatch.setattr(
settings_module.settings, "GRAPHRAG_ENABLED", True, raising=False
@@ -251,7 +251,7 @@ class TestGraphNodeReembedLive:
assert all(v[0] == pytest.approx(1.0) for _, v in _node_vectors(live_dsn, GRAPH_SOURCE))
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=_Embeddings(9.0),
):
reembed.reembed_pgvector(GRAPH_SOURCE, batch_size=64, dry_run=False)
@@ -263,7 +263,7 @@ class TestGraphNodeReembedLive:
)
def test_graph_is_left_alone_when_graphrag_is_off(self, live_dsn, monkeypatch):
from application.core import settings as settings_module
from docsgpt.core import settings as settings_module
monkeypatch.setattr(
settings_module.settings, "GRAPHRAG_ENABLED", False, raising=False
@@ -272,7 +272,7 @@ class TestGraphNodeReembedLive:
_seed_graph_node(live_dsn, GRAPH_SOURCE, "Alpha", 1.0)
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=_Embeddings(9.0),
):
reembed.reembed_pgvector(GRAPH_SOURCE, batch_size=64, dry_run=False)
@@ -280,7 +280,7 @@ class TestGraphNodeReembedLive:
assert all(v[0] == pytest.approx(1.0) for _, v in _node_vectors(live_dsn, GRAPH_SOURCE))
def test_dry_run_leaves_node_vectors_untouched(self, live_dsn, monkeypatch):
from application.core import settings as settings_module
from docsgpt.core import settings as settings_module
monkeypatch.setattr(
settings_module.settings, "GRAPHRAG_ENABLED", True, raising=False
@@ -289,7 +289,7 @@ class TestGraphNodeReembedLive:
_seed_graph_node(live_dsn, GRAPH_SOURCE, "Alpha", 1.0)
with patch(
"application.vectorstore.base.BaseVectorStore._get_embeddings",
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
return_value=_Embeddings(9.0),
):
reembed.reembed_pgvector(GRAPH_SOURCE, batch_size=64, dry_run=True)
+5 -5
View File
@@ -4,7 +4,7 @@ import sys
import types
from unittest.mock import patch
from application.scripts import verify_offline
from docsgpt.scripts import verify_offline
def _fake_tiktoken(monkeypatch):
@@ -17,8 +17,8 @@ class TestVerify:
def test_passes_when_every_check_passes(self, monkeypatch, capsys):
_fake_tiktoken(monkeypatch)
counter = types.SimpleNamespace(name="org/model", count=lambda text: 4)
with patch("application.parser.tokenization.get_token_counter", return_value=counter), \
patch("application.vectorstore.embeddings_local.EmbeddingsWrapper") as wrapper, \
with patch("docsgpt.parser.tokenization.get_token_counter", return_value=counter), \
patch("docsgpt.vectorstore.embeddings_local.EmbeddingsWrapper") as wrapper, \
patch.object(verify_offline, "is_available", return_value=False):
wrapper.return_value.embed_query.return_value = [0.0] * 768
assert verify_offline.verify(["ibm-granite/granite-embedding-311m-multilingual-r2"]) is True
@@ -30,8 +30,8 @@ class TestVerify:
"""A cache miss makes chunking silently use cl100k; that is a failed check."""
_fake_tiktoken(monkeypatch)
counter = types.SimpleNamespace(name="cl100k_base", count=lambda text: 4)
with patch("application.parser.tokenization.get_token_counter", return_value=counter), \
patch("application.vectorstore.embeddings_local.EmbeddingsWrapper") as wrapper, \
with patch("docsgpt.parser.tokenization.get_token_counter", return_value=counter), \
patch("docsgpt.vectorstore.embeddings_local.EmbeddingsWrapper") as wrapper, \
patch.object(verify_offline, "is_available", return_value=False):
wrapper.return_value.embed_query.return_value = [0.0] * 768
assert verify_offline.verify(["ibm-granite/granite-embedding-311m-multilingual-r2"]) is False