mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-16 22:14:07 +00:00
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:
1 parent
3e7f1f91b4
commit
574f96341e
984 files changed
+9847
-9682
No files matched your search
@@ -13,10 +13,10 @@ import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
import application.graphrag.extraction as extraction_module
|
||||
from application.graphrag.store import GraphStore
|
||||
from application.storage.db.source_config import SourceConfig
|
||||
from application.vectorstore import pgconn
|
||||
import docsgpt.graphrag.extraction as extraction_module
|
||||
from docsgpt.graphrag.store import GraphStore
|
||||
from docsgpt.storage.db.source_config import SourceConfig
|
||||
from docsgpt.vectorstore import pgconn
|
||||
|
||||
extract_graph_for_source = extraction_module.extract_graph_for_source
|
||||
|
||||
@@ -55,7 +55,7 @@ def _live_store(monkeypatch, info):
|
||||
dsn = _ephemeral_dsn(info)
|
||||
# The pipeline builds its own GraphStore() from settings, so point those at
|
||||
# the ephemeral cluster too — never at the operator's configured DB.
|
||||
from application.core import settings as settings_module
|
||||
from docsgpt.core import settings as settings_module
|
||||
|
||||
monkeypatch.setattr(
|
||||
settings_module.settings, "PGVECTOR_CONNECTION_STRING", dsn, raising=False
|
||||
@@ -103,7 +103,7 @@ class _StubEmbedding:
|
||||
|
||||
@pytest.fixture
|
||||
def stub_embedding(monkeypatch):
|
||||
from application.core.settings import settings
|
||||
from docsgpt.core.settings import settings
|
||||
|
||||
# The resolver short-circuits to the remote API when this is configured,
|
||||
# which would bypass the stub on a dev machine that sets it.
|
||||
@@ -436,7 +436,7 @@ class TestEmbeddingsResolution:
|
||||
fake_store = MagicMock()
|
||||
fake_store.pending_chunks.return_value = []
|
||||
monkeypatch.setattr(
|
||||
"application.graphrag.store.GraphStore", lambda *a, **k: fake_store
|
||||
"docsgpt.graphrag.store.GraphStore", lambda *a, **k: fake_store
|
||||
)
|
||||
_install_stub_llm(monkeypatch, _StubLLM([]))
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from application.graphrag import graphrag_available
|
||||
from application.core.settings import settings
|
||||
from docsgpt.graphrag import graphrag_available
|
||||
from docsgpt.core.settings import settings
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
|
||||
@@ -15,8 +15,8 @@ from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from application.retriever.graph_rag import GraphRAGRetriever
|
||||
from application.vectorstore import pgconn
|
||||
from docsgpt.retriever.graph_rag import GraphRAGRetriever
|
||||
from docsgpt.vectorstore import pgconn
|
||||
|
||||
pytestmark = pytest.mark.integration
|
||||
|
||||
@@ -64,12 +64,12 @@ def _close_pools():
|
||||
def stub_embeddings():
|
||||
stub = _StubEmbeddings()
|
||||
with patch(
|
||||
"application.vectorstore.base.get_embeddings", return_value=stub
|
||||
"docsgpt.vectorstore.base.get_embeddings", return_value=stub
|
||||
), patch(
|
||||
"application.vectorstore.base.BaseVectorStore._get_embeddings",
|
||||
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
|
||||
return_value=stub,
|
||||
), patch(
|
||||
"application.retriever.graph_rag.get_embeddings", return_value=stub
|
||||
"docsgpt.retriever.graph_rag.get_embeddings", return_value=stub
|
||||
):
|
||||
yield stub
|
||||
|
||||
@@ -86,7 +86,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)
|
||||
@@ -99,8 +99,8 @@ def live_dsn(postgresql, monkeypatch):
|
||||
|
||||
def _seed(dsn, graph_source_id):
|
||||
"""Ingest one chunk and one graph node for ``graph_source_id``."""
|
||||
from application.graphrag.store import GraphStore
|
||||
from application.vectorstore.pgvector import PGVectorStore
|
||||
from docsgpt.graphrag.store import GraphStore
|
||||
from docsgpt.vectorstore.pgvector import PGVectorStore
|
||||
|
||||
vector_store = PGVectorStore(
|
||||
source_id=graph_source_id, connection_string=dsn
|
||||
@@ -132,7 +132,7 @@ def _seed(dsn, graph_source_id):
|
||||
|
||||
def _retriever(sources):
|
||||
with patch(
|
||||
"application.retriever.classic_rag.LLMCreator.create_llm",
|
||||
"docsgpt.retriever.classic_rag.LLMCreator.create_llm",
|
||||
Mock(return_value=MagicMock()),
|
||||
):
|
||||
return GraphRAGRetriever(
|
||||
@@ -194,7 +194,7 @@ class TestGraphRAGRetrieverLive:
|
||||
def test_all_graphless_sources_take_one_classic_call(
|
||||
self, live_dsn, stub_embeddings
|
||||
):
|
||||
from application.graphrag.store import GraphStore
|
||||
from docsgpt.graphrag.store import GraphStore
|
||||
|
||||
store = GraphStore(connection_string=live_dsn)
|
||||
store._ensure_tables() # tables exist, but no source has a graph
|
||||
|
||||
@@ -20,9 +20,9 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
import application.graphrag.store as store_module
|
||||
from application.vectorstore import pgconn
|
||||
from application.vectorstore import pgvector as pgvector_module
|
||||
import docsgpt.graphrag.store as store_module
|
||||
from docsgpt.vectorstore import pgconn
|
||||
from docsgpt.vectorstore import pgvector as pgvector_module
|
||||
|
||||
GraphStore = store_module.GraphStore
|
||||
|
||||
@@ -374,13 +374,13 @@ class TestGraphStoreLive:
|
||||
|
||||
def test_the_vector_store_reuses_the_graph_store_pool(self, store, postgresql):
|
||||
"""Same DSN, one pool: the graph store does not double the connections."""
|
||||
from application.vectorstore.pgvector import PGVectorStore
|
||||
from docsgpt.vectorstore.pgvector import PGVectorStore
|
||||
|
||||
stub = MagicMock()
|
||||
stub.dimension = TEST_EMBEDDING_DIM
|
||||
stub.embed_query.return_value = [0.0] * TEST_EMBEDDING_DIM
|
||||
with patch(
|
||||
"application.vectorstore.base.BaseVectorStore._get_embeddings",
|
||||
"docsgpt.vectorstore.base.BaseVectorStore._get_embeddings",
|
||||
return_value=stub,
|
||||
):
|
||||
vector_store = PGVectorStore(
|
||||
@@ -462,7 +462,7 @@ class TestGraphStoreParameterization:
|
||||
assert params == (embedding, sid, embedding, 5)
|
||||
|
||||
def test_graph_overview_binds_source_and_clamps_limit(self):
|
||||
from application.graphrag.store import GRAPH_OVERVIEW_MAX_LIMIT
|
||||
from docsgpt.graphrag.store import GRAPH_OVERVIEW_MAX_LIMIT
|
||||
|
||||
store, cursor = self._store_with_mock_conn()
|
||||
cursor.fetchall.return_value = []
|
||||
@@ -499,7 +499,7 @@ class TestEmbeddingDim:
|
||||
"""The graph table dimension is derived from the configured model (FIX 1)."""
|
||||
|
||||
def test_uses_configured_model_dimension(self, monkeypatch):
|
||||
from application.vectorstore import base as base_module
|
||||
from docsgpt.vectorstore import base as base_module
|
||||
|
||||
monkeypatch.setattr(base_module.settings, "EMBEDDINGS_BASE_URL", None)
|
||||
fake_embedding = MagicMock()
|
||||
@@ -520,7 +520,7 @@ class TestEmbeddingDim:
|
||||
``getattr`` with a default cannot catch that -- the attribute exists --
|
||||
so the width reached the DDL as ``vector(None)``.
|
||||
"""
|
||||
from application.vectorstore import base as base_module
|
||||
from docsgpt.vectorstore import base as base_module
|
||||
|
||||
monkeypatch.setattr(base_module.settings, "EMBEDDINGS_BASE_URL", None)
|
||||
fake_embedding = MagicMock()
|
||||
@@ -536,7 +536,7 @@ class TestEmbeddingDim:
|
||||
assert store._embedding_dim() == store_module.DEFAULT_NAME_EMBEDDING_DIM
|
||||
|
||||
def test_falls_back_to_default_dimension(self, monkeypatch):
|
||||
from application.vectorstore import base as base_module
|
||||
from docsgpt.vectorstore import base as base_module
|
||||
|
||||
monkeypatch.setattr(base_module.settings, "EMBEDDINGS_BASE_URL", None)
|
||||
fake_embedding = object()
|
||||
@@ -562,7 +562,7 @@ class TestEmbeddingDimResolution:
|
||||
monkeypatch.setattr(GraphStore, "_embedding_dim", _REAL_EMBEDDING_DIM)
|
||||
|
||||
with patch(
|
||||
"application.vectorstore.base.get_embeddings",
|
||||
"docsgpt.vectorstore.base.get_embeddings",
|
||||
return_value=fake_embedding,
|
||||
) as mock_resolver:
|
||||
store = GraphStore.__new__(GraphStore)
|
||||
|
||||
Reference in new issue
Block a user