Rename the package roledesk to app
The boilerplate's rule: the deploy kit's Dockerfile, the APP_CONFIG, APP_PASSWORD and APP_DATA variables and its commands all assume a package called app, so a project renames its display title and nothing else. The console script is `app`, and the launch entry runs `uv run app serve --port 8790`. The domain noun stays `role`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
248ea1636d
commit
7a63311714
32 files changed
+102
-98
No files matched your search
+1
-1
@@ -6,7 +6,7 @@
|
||||
"runtimeExecutable": "uv",
|
||||
"runtimeArgs": [
|
||||
"run",
|
||||
"roledesk",
|
||||
"app",
|
||||
"serve",
|
||||
"--port",
|
||||
"8790"
|
||||
|
||||
@@ -27,4 +27,8 @@ Good example:
|
||||
|
||||
# Rule:
|
||||
|
||||
`desk` and `pipeline` are imported from ../news and never edited here.
|
||||
The package is `app`, following the boilerplate: the deploy kit, `APP_CONFIG`, `APP_PASSWORD` and `APP_DATA` assume that name. The domain noun is `role`, so "job" only ever means queued work.
|
||||
|
||||
# Rule:
|
||||
|
||||
`pipeline/`, `auth/` and `deploy/` are downstream copies of `../boilerplate`, `desk/` of `../news`. They are refreshed with `git archive`, and a fix lands upstream first, otherwise the next refresh reverts it.
|
||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
||||
"""`roledesk serve | job pull|extract|embed|score | companies seed|add|check | db init`."""
|
||||
"""`app serve | job pull|extract|embed|score | companies seed|add|check | db init`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -9,12 +9,12 @@ import sys
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from roledesk import config as config_mod
|
||||
from app import config as config_mod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from roledesk.storage import Store
|
||||
from app.storage import Store
|
||||
|
||||
#: The one plugin this app ships lives outside the `roledesk` package, in
|
||||
#: The one plugin this app ships lives outside the `app` package, in
|
||||
#: `plugins/`, so it is discovered by `desk.sources.registry` the same way a
|
||||
#: user's own drop-in plugin would be. `companies` and `job pull` both want
|
||||
#: its plain functions (`is_known_target`, `careers_url`, `fetch_board`) as
|
||||
@@ -26,7 +26,7 @@ if str(_ROOT) not in sys.path:
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(prog="roledesk",
|
||||
parser = argparse.ArgumentParser(prog="app",
|
||||
description="A job-search engine on desk.")
|
||||
parser.add_argument("-c", "--config", default=None, help="path to roles.yaml")
|
||||
parser.add_argument("-v", "--verbose", action="store_true")
|
||||
@@ -60,7 +60,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
format="%(asctime)s %(levelname)s %(name)s: %(message)s")
|
||||
try:
|
||||
if args.command == "serve":
|
||||
from roledesk.web import serve
|
||||
from app.web import serve
|
||||
config_mod.load(args.config) # a config error here, not in uvicorn
|
||||
return serve(args.host, args.port, args.config)
|
||||
if args.command == "job":
|
||||
@@ -79,8 +79,8 @@ def run_job(args: argparse.Namespace) -> int:
|
||||
ended: one line per task, from each task's final job. `pull` is a
|
||||
cascade, so it prints a line for every stage it went through."""
|
||||
from pipeline import FINAL, JobQueue, Jobs, TASKS
|
||||
from roledesk import jobs
|
||||
from roledesk.storage import Store
|
||||
from app import jobs
|
||||
from app.storage import Store
|
||||
|
||||
config = config_mod.load(args.config)
|
||||
store = Store(config.database)
|
||||
@@ -117,7 +117,7 @@ def run_job(args: argparse.Namespace) -> int:
|
||||
|
||||
|
||||
def run_companies(args: argparse.Namespace) -> int:
|
||||
from roledesk.storage import Store
|
||||
from app.storage import Store
|
||||
|
||||
config = config_mod.load(args.config)
|
||||
store = Store(config.database)
|
||||
@@ -162,11 +162,11 @@ def seed_companies(store: Store, path: str) -> dict[str, int]:
|
||||
|
||||
|
||||
def add_company(store: Store, board: str, name: str) -> int:
|
||||
"""`roledesk companies add greenhouse:acme "Acme"`: fetch the board first
|
||||
"""`app companies add greenhouse:acme "Acme"`: fetch the board first
|
||||
and refuse if it does not answer, is not a known host, or the company
|
||||
already exists. Port of seedgen's `-add`."""
|
||||
from plugins.ats import careers_url as careers_url_of, fetch_board, is_known_target
|
||||
from roledesk.models import company_key
|
||||
from app.models import company_key
|
||||
|
||||
if not is_known_target(board):
|
||||
print(f"companies add: {board!r} is not host:slug for a known ATS host",
|
||||
@@ -197,7 +197,7 @@ def add_company(store: Store, board: str, name: str) -> int:
|
||||
|
||||
|
||||
def check_companies(store: Store) -> int:
|
||||
"""`roledesk companies check`: every `ats` board, fetched once. Prints a
|
||||
"""`app companies check`: every `ats` board, fetched once. Prints a
|
||||
line per board that did not answer and exits 1 if any did not."""
|
||||
from plugins.ats import fetch_board
|
||||
|
||||
@@ -216,7 +216,7 @@ def check_companies(store: Store) -> int:
|
||||
|
||||
def init_db(args: argparse.Namespace) -> int:
|
||||
"""Create the file, or bring it to the current schema."""
|
||||
from roledesk.storage import LATEST, Store
|
||||
from app.storage import LATEST, Store
|
||||
|
||||
config = config_mod.load(args.config)
|
||||
store = Store(config.database)
|
||||
@@ -14,14 +14,14 @@ import yaml
|
||||
from pydantic import Field, ValidationError
|
||||
|
||||
from desk.config import AgentConfig, ModelTaskConfig, Section, WorkersConfig
|
||||
from roledesk.models import Gate, Weights
|
||||
from app.models import Gate, Weights
|
||||
|
||||
DEFAULT_PATH = Path(os.environ.get("ROLEDESK_CONFIG", "roles.yaml"))
|
||||
|
||||
|
||||
class ExtractConfig(ModelTaskConfig):
|
||||
"""Turning a posting's title and text into the gate columns. See
|
||||
roledesk/jobs/extract.py. Off by default, so nobody is billed by surprise:
|
||||
app/jobs/extract.py. Off by default, so nobody is billed by surprise:
|
||||
on the API backend every batch is a paid call."""
|
||||
|
||||
enabled: bool = False
|
||||
@@ -32,7 +32,7 @@ class ExtractConfig(ModelTaskConfig):
|
||||
class EmbedConfig(Section):
|
||||
"""Turning a role into a vector for `fit`. Needs sentence-transformers;
|
||||
without it `embed` says so and does nothing, and `score` leaves fit out.
|
||||
See roledesk/jobs/embed.py."""
|
||||
See app/jobs/embed.py."""
|
||||
|
||||
#: Recorded on every vector. Changing it drops the old vectors, which are
|
||||
#: a different geometry and never comparable.
|
||||
@@ -10,18 +10,18 @@ every task in `pipeline.TASKS`.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from roledesk.jobs import cascade, embed, extract, pull, score
|
||||
from roledesk.jobs.score import seed_agents
|
||||
from app.jobs import cascade, embed, extract, pull, score
|
||||
from app.jobs.score import seed_agents
|
||||
|
||||
#: What `JobQueue(bootstrap=...)` and `pipeline.worker --bootstrap` are given.
|
||||
BOOTSTRAP = "roledesk.jobs:bootstrap"
|
||||
BOOTSTRAP = "app.jobs:bootstrap"
|
||||
|
||||
|
||||
def bootstrap(config_path: str = "") -> tuple[object, object]:
|
||||
"""roledesk's `(config, store)` from the config file alone, for a job run
|
||||
in its own process or by `python -m pipeline.worker`."""
|
||||
from roledesk import config as config_mod
|
||||
from roledesk.storage import Store
|
||||
from app import config as config_mod
|
||||
from app.storage import Store
|
||||
|
||||
config = config_mod.load(config_path or None)
|
||||
return config, Store(config.database)
|
||||
@@ -26,9 +26,9 @@ from typing import Any
|
||||
|
||||
from desk.tools import agent
|
||||
from pipeline import TASKS, Tally, Task
|
||||
from roledesk.jobs import embed, extract, pull, score # noqa: F401 -- registers the jobs
|
||||
from app.jobs import embed, extract, pull, score # noqa: F401 -- registers the jobs
|
||||
|
||||
STEP = "roledesk.jobs.cascade:step"
|
||||
STEP = "app.jobs.cascade:step"
|
||||
|
||||
CASCADES: dict[str, tuple[str, ...]] = {
|
||||
"pull": ("pull", "extract", "embed", "score"),
|
||||
@@ -98,7 +98,7 @@ def step(config: Any, store: Any, tally: Tally, payload: dict[str, Any], *,
|
||||
return out
|
||||
|
||||
|
||||
#: What `roledesk job <name>` and the Jobs view offer. `pull` is the whole
|
||||
#: What `app job <name>` and the Jobs view offer. `pull` is the whole
|
||||
#: chain; the others are one stage each, on their own.
|
||||
TASKS["pull"] = partial(task, "pull", cascade="pull")
|
||||
for _name in ("extract", "embed", "score"):
|
||||
@@ -16,9 +16,9 @@ from typing import Any
|
||||
|
||||
from desk.tools import embedding
|
||||
from pipeline import NULL, Notice, RunContext, job
|
||||
from roledesk.config import Config
|
||||
from roledesk.models import Role
|
||||
from roledesk.storage import Store
|
||||
from app.config import Config
|
||||
from app.models import Role
|
||||
from app.storage import Store
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -49,7 +49,7 @@ def unavailable(exc: BaseException) -> Notice:
|
||||
"and scores leave fit out.",
|
||||
fix="Install it into roledesk's environment: "
|
||||
"`uv pip install sentence-transformers`.",
|
||||
detail=str(exc), where="roledesk.jobs.embed")
|
||||
detail=str(exc), where="app.jobs.embed")
|
||||
|
||||
|
||||
@job("embed", "Embedding roles", solo=True, resource="cpu")
|
||||
@@ -28,9 +28,9 @@ from typing import Any
|
||||
from desk import modeltask
|
||||
from desk.modeltask import ModelTask
|
||||
from pipeline import NULL, RunContext, Task, job
|
||||
from roledesk.config import Config
|
||||
from roledesk.models import PERMITS, REMOTE, SENIORITIES, ExtractResult, Role
|
||||
from roledesk.storage import Store
|
||||
from app.config import Config
|
||||
from app.models import PERMITS, REMOTE, SENIORITIES, ExtractResult, Role
|
||||
from app.storage import Store
|
||||
|
||||
# `FUNCTIONS` is the `ats` plugin's vocabulary, reached the way `web/pages.py`
|
||||
# reaches it, so the classifier and the model answer in the same nine words.
|
||||
@@ -22,8 +22,8 @@ from typing import Any
|
||||
|
||||
from pipeline import NULL, RunContext, Tally, Task, job
|
||||
|
||||
from roledesk.config import Config
|
||||
from roledesk.storage import Store
|
||||
from app.config import Config
|
||||
from app.storage import Store
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -32,7 +32,7 @@ log = logging.getLogger(__name__)
|
||||
#: holding all 190-odd boards' worth of retries against a single attempt.
|
||||
BATCH_SIZE = 10
|
||||
|
||||
SETTLE = "roledesk.jobs.pull:close_boards"
|
||||
SETTLE = "app.jobs.pull:close_boards"
|
||||
|
||||
|
||||
def _now() -> str:
|
||||
@@ -104,7 +104,7 @@ def close_boards(config: Config, store: Store, tally: Tally, *,
|
||||
|
||||
|
||||
def pull_task() -> Task:
|
||||
"""The pull on its own. `roledesk.jobs.cascade` makes it the first stage
|
||||
"""The pull on its own. `app.jobs.cascade` makes it the first stage
|
||||
of the chain that `TASKS["pull"]` starts."""
|
||||
return Task(kind="pull_batch", finder=_boards, name="pull",
|
||||
label="Reading every board", settle=SETTLE)
|
||||
@@ -32,10 +32,10 @@ from typing import Any
|
||||
import numpy as np
|
||||
|
||||
from pipeline import NULL, RunContext, job
|
||||
from roledesk.config import Config
|
||||
from roledesk.jobs import embed
|
||||
from roledesk.models import Agent, Candidate, Gate, Weights
|
||||
from roledesk.storage import Store
|
||||
from app.config import Config
|
||||
from app.jobs import embed
|
||||
from app.models import Agent, Candidate, Gate, Weights
|
||||
from app.storage import Store
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -139,7 +139,7 @@ class Role(Model):
|
||||
|
||||
|
||||
class ExtractResult(ModelTaskResult):
|
||||
"""What one run of `extract` did. See roledesk/jobs/extract.py."""
|
||||
"""What one run of `extract` did. See app/jobs/extract.py."""
|
||||
|
||||
#: Roles the model answered for, whether or not it found anything to fill.
|
||||
extracted: int = 0
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Where things are kept. One door: `from roledesk.storage import Store`.
|
||||
"""Where things are kept. One door: `from app.storage import Store`.
|
||||
|
||||
schema.py the tables, and the numbered migrations that bring an older
|
||||
file to the current shape
|
||||
@@ -10,7 +10,7 @@ package on purpose, and the connection plumbing here is a deliberate copy.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from roledesk.storage.schema import LATEST
|
||||
from roledesk.storage.store import Store
|
||||
from app.storage.schema import LATEST
|
||||
from app.storage.store import Store
|
||||
|
||||
__all__ = ["LATEST", "Store"]
|
||||
File renamed without changes.
@@ -20,12 +20,12 @@ from uuid import uuid4
|
||||
import numpy as np
|
||||
|
||||
from desk.models import Item
|
||||
from roledesk.models import (
|
||||
from app.models import (
|
||||
AFFINITY, REMOTE, STATUSES, Agent, Application, ApplicationEvent, Candidate,
|
||||
Company, Gate, Role, ScoredRole, Subscription, Weights, company_key, place_key,
|
||||
title_key,
|
||||
)
|
||||
from roledesk.storage import schema
|
||||
from app.storage import schema
|
||||
|
||||
#: Text columns a plugin may fill from `Item.raw` under the same name. An
|
||||
#: empty value never overwrites a filled column, so an upsert from a board that
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from roledesk.web.app import create_app, serve
|
||||
from app.web.app import create_app, serve
|
||||
|
||||
__all__ = ["create_app", "serve"]
|
||||
@@ -12,10 +12,10 @@ from typing import Annotated
|
||||
from fastapi import APIRouter, HTTPException, Query, Response
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from roledesk.models import (
|
||||
from app.models import (
|
||||
AFFINITY, Agent, Application, Company, Gate, ScoredRole, Status, Weights,
|
||||
)
|
||||
from roledesk.web.deps import StoreDep
|
||||
from app.web.deps import StoreDep
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["roledesk"])
|
||||
|
||||
@@ -10,11 +10,11 @@ from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from pipeline import Jobs
|
||||
from pipeline.web import connect
|
||||
from roledesk import config as config_mod
|
||||
from roledesk import jobs
|
||||
from roledesk.storage import Store
|
||||
from roledesk.web.api import router as api_router
|
||||
from roledesk.web.pages import router as pages_router
|
||||
from app import config as config_mod
|
||||
from app import jobs
|
||||
from app.storage import Store
|
||||
from app.web.api import router as api_router
|
||||
from app.web.pages import router as pages_router
|
||||
|
||||
WEB = Path(__file__).resolve().parent
|
||||
|
||||
@@ -6,7 +6,7 @@ it as a dependency rather than closing over it, the same split newsdesk's
|
||||
importable, and testable, on its own.
|
||||
|
||||
Not a `yield` dependency: `Store` holds no connection between calls (see
|
||||
`roledesk/storage/store.py`), so there is nothing to close, and building one
|
||||
`app/storage/store.py`), so there is nothing to close, and building one
|
||||
per request would take SQLite's write lock for a plain read.
|
||||
"""
|
||||
|
||||
@@ -17,7 +17,7 @@ from typing import Annotated
|
||||
from fastapi import Depends
|
||||
from starlette.requests import HTTPConnection
|
||||
|
||||
from roledesk.storage import Store
|
||||
from app.storage import Store
|
||||
|
||||
|
||||
def get_store(request: HTTPConnection) -> Store:
|
||||
@@ -3,10 +3,10 @@ hands the browser an empty shell — the filter bar, the section headers, the
|
||||
`<select>` options a plugin's vocabulary decides — and `static/app.js` fills
|
||||
it and drives every action from there.
|
||||
|
||||
`FUNCTIONS` is `plugins.ats`'s, not `roledesk`'s: the nine job functions are
|
||||
`FUNCTIONS` is `plugins.ats`'s, not `app`'s: the nine job functions are
|
||||
the classifier's vocabulary, and this reaches `plugins/` the same way
|
||||
`roledesk.cli` already does, since a plugin is app-agnostic and never reaches
|
||||
back into `roledesk`.
|
||||
`app.cli` already does, since a plugin is app-agnostic and never reaches
|
||||
back into `app`.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -18,7 +18,7 @@ from fastapi import APIRouter, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from roledesk.models import REMOTE, STATUSES
|
||||
from app.models import REMOTE, STATUSES
|
||||
|
||||
_ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(_ROOT) not in sys.path:
|
||||
File renamed without changes.
File renamed without changes.
@@ -120,7 +120,7 @@
|
||||
|
||||
<script>
|
||||
// The tracker's status vocabulary, from the same `STATUSES` tuple the
|
||||
// store validates a status change against — see roledesk/web/pages.py.
|
||||
// store validates a status change against — see app/web/pages.py.
|
||||
window.ROLEDESK_STATUSES = {{ status_options | map(attribute=0) | list | tojson }};
|
||||
</script>
|
||||
<script src="/static/app.js" defer></script>
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
# roledesk configuration. `roles.yaml` is the one the app reads by default
|
||||
# (or $ROLEDESK_CONFIG, or `roledesk -c path`). Every key here is optional.
|
||||
# (or $ROLEDESK_CONFIG, or `app -c path`). Every key here is optional.
|
||||
|
||||
# The SQLite file: roles, companies, subscriptions, applications, and the
|
||||
# job queue's own table. Not shared with newsdesk.
|
||||
@@ -20,14 +20,14 @@ workers:
|
||||
agent:
|
||||
backend: auto # auto | api | claude_code | off
|
||||
|
||||
# Title and description in, gate columns out (roledesk/jobs/extract.py). Off by
|
||||
# Title and description in, gate columns out (app/jobs/extract.py). Off by
|
||||
# default: on the API backend every batch of 20 roles is a paid call.
|
||||
extract:
|
||||
enabled: false
|
||||
model: claude-haiku-4-5-20251001
|
||||
|
||||
# A role and each agent's intent as vectors, for the fit term of a score
|
||||
# (roledesk/jobs/embed.py). Needs sentence-transformers; without it `embed`
|
||||
# (app/jobs/embed.py). Needs sentence-transformers; without it `embed`
|
||||
# posts a notice and scores leave fit out. Changing the model re-embeds.
|
||||
embed:
|
||||
model: sentence-transformers/all-MiniLM-L6-v2
|
||||
|
||||
+4
-4
@@ -453,7 +453,7 @@ def classify(department: str, title: str) -> str:
|
||||
|
||||
def is_known_target(target: str) -> bool:
|
||||
"""`host:slug`, with `host` one of `_BOARDS` and a non-empty slug. What
|
||||
the target validator refuses: `roledesk companies add` and the pull job
|
||||
the target validator refuses: `app companies add` and the pull job
|
||||
both call this before touching the network."""
|
||||
host, sep, slug = target.partition(":")
|
||||
return bool(sep) and host in _BOARDS and bool(slug.strip())
|
||||
@@ -461,7 +461,7 @@ def is_known_target(target: str) -> bool:
|
||||
|
||||
def careers_url(target: str) -> str:
|
||||
"""The company's own careers page for `host:slug`, or "" for an unknown
|
||||
host. What `roledesk companies add` stores alongside the board."""
|
||||
host. What `app companies add` stores alongside the board."""
|
||||
host, _, slug = target.partition(":")
|
||||
if host not in _BOARDS:
|
||||
return ""
|
||||
@@ -493,7 +493,7 @@ def _fetch_rows(client: httpx.Client, target: str) -> list[Row]:
|
||||
|
||||
def fetch_board(target: str) -> list[Row]:
|
||||
"""Fetch and parse one board directly: no `Source`, no `self.state`, just
|
||||
"does this board answer, and what does it list". For `roledesk companies
|
||||
"does this board answer, and what does it list". For `app companies
|
||||
add|check`, which ask that question about one board at a time outside any
|
||||
pull. Raises the same way `_fetch_rows` does."""
|
||||
with httpx.Client() as client:
|
||||
@@ -528,7 +528,7 @@ class ATSSource(Source):
|
||||
def fetch(self) -> Iterator[Item]:
|
||||
client = httpx.Client()
|
||||
# Written by the pull job before any board is fetched (see
|
||||
# `roledesk/jobs/pull.py`); a plugin run on its own — a test, a dry
|
||||
# `app/jobs/pull.py`); a plugin run on its own — a test, a dry
|
||||
# run — has no run to stamp itself against, so it makes one up.
|
||||
run_marker = self.state.get("ats:run", "") or datetime.now(UTC).isoformat(
|
||||
timespec="seconds")
|
||||
|
||||
+4
-4
@@ -15,14 +15,14 @@ dependencies = [
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
roledesk = "roledesk.cli:main"
|
||||
app = "app.cli:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=68"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
include = ["roledesk*"]
|
||||
include = ["app*"]
|
||||
|
||||
[tool.uv.sources]
|
||||
newsdesk = { path = "../news", editable = true }
|
||||
@@ -54,13 +54,13 @@ ignore = [
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
# Pydantic models whose base comes from `desk.models`; ruff only recognises a
|
||||
# pydantic subclass when it sees `BaseModel` in the same file.
|
||||
"roledesk/models.py" = ["RUF012"]
|
||||
"app/models.py" = ["RUF012"]
|
||||
|
||||
# ------------------------------------------------------------ type checking
|
||||
|
||||
[tool.mypy]
|
||||
python_version = "3.14"
|
||||
files = ["roledesk", "tests"]
|
||||
files = ["app", "tests"]
|
||||
plugins = ["pydantic.mypy"]
|
||||
# The editable install of ../news is a setuptools import hook, which mypy
|
||||
# cannot follow. Pointed at the checkout instead, and told to type what it
|
||||
|
||||
+11
-11
@@ -1,15 +1,15 @@
|
||||
"""The package boundaries, held as a test rather than as a convention.
|
||||
|
||||
Adapted from news/tests/test_architecture.py. One tree of our own, `roledesk`,
|
||||
Adapted from news/tests/test_architecture.py. One tree of our own, `app`,
|
||||
and two external ones, `desk` and `pipeline`, imported from ../news.
|
||||
|
||||
1. **Direction.** Within `roledesk`, a package imports only from packages below
|
||||
1. **Direction.** Within `app`, a package imports only from packages below
|
||||
it in `LAYERS`. `desk` and `pipeline` may be imported by any of them.
|
||||
2. **Doors.** From outside a package, only `<tree>.<package>` is imported, and
|
||||
only names it lists in `__all__`. `desk.tools` has no door of its own, so
|
||||
there the door is the tool: `desk.tools.<tool>`, one level, no deeper.
|
||||
3. **Plugins.** A file under `plugins/` imports `desk` and nothing else from
|
||||
these trees. A plugin is app-agnostic; it never sees `roledesk`.
|
||||
these trees. A plugin is app-agnostic; it never sees `app`.
|
||||
|
||||
Tests are held to none of this.
|
||||
"""
|
||||
@@ -27,7 +27,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
#: Bottom to top. `cli` is the entry point and may reach anything.
|
||||
LAYERS = ["models", "config", "storage", "jobs", "web", "cli"]
|
||||
APP = "roledesk"
|
||||
APP = "app"
|
||||
EXTERNAL = {"desk", "pipeline"}
|
||||
TREES = {APP} | EXTERNAL
|
||||
|
||||
@@ -73,7 +73,7 @@ def _door_violation(module: str, names: list[str]) -> str | None:
|
||||
|
||||
|
||||
def _package(path: Path) -> str:
|
||||
"""`roledesk/storage/store.py` -> "storage"; `roledesk/cli.py` -> "cli";
|
||||
"""`app/storage/store.py` -> "storage"; `app/cli.py` -> "cli";
|
||||
the tree's own `__init__.py` -> "" (a door, exempt from direction)."""
|
||||
rel = path.relative_to(ROOT).parts
|
||||
name = rel[1].removesuffix(".py") if len(rel) > 1 else ""
|
||||
@@ -100,7 +100,7 @@ def direction_violations(here: str, source: str) -> list[str]:
|
||||
if parts[0] != APP or not here or len(parts) < 2 or parts[1] not in LAYERS:
|
||||
continue
|
||||
if LAYERS.index(parts[1]) >= LAYERS.index(here):
|
||||
wrong.append(f"line {line}: {module} is not below roledesk.{here}")
|
||||
wrong.append(f"line {line}: {module} is not below app.{here}")
|
||||
return wrong
|
||||
|
||||
|
||||
@@ -137,17 +137,17 @@ def test_a_plugin_knows_only_desk(path: Path) -> None:
|
||||
|
||||
def test_the_rules_catch_what_they_are_for() -> None:
|
||||
"""The checker itself, on sources that break each rule."""
|
||||
assert plugin_violations("from roledesk.storage import Store")
|
||||
assert plugin_violations("from app.storage import Store")
|
||||
assert plugin_violations("from pipeline import job")
|
||||
assert plugin_violations("from desk.sources.base import Source")
|
||||
assert not plugin_violations("from desk.sources import Source, Item")
|
||||
|
||||
assert direction_violations("storage", "from roledesk.web import create_app")
|
||||
assert direction_violations("storage", "from roledesk import jobs")
|
||||
assert not direction_violations("jobs", "from roledesk.storage import Store")
|
||||
assert direction_violations("storage", "from app.web import create_app")
|
||||
assert direction_violations("storage", "from app import jobs")
|
||||
assert not direction_violations("jobs", "from app.storage import Store")
|
||||
assert not direction_violations("models", "from pipeline import job")
|
||||
|
||||
assert _door_violation("roledesk.storage.store", ["Store"])
|
||||
assert _door_violation("app.storage.store", ["Store"])
|
||||
assert _door_violation("desk.tools.video.marks", [])
|
||||
assert _door_violation("pipeline", ["not_exported_name"])
|
||||
assert not _door_violation("pipeline.web", ["connect"])
|
||||
@@ -12,9 +12,9 @@ import pytest
|
||||
from desk import modeltask
|
||||
from desk.models import Item
|
||||
from desk.tools import agent
|
||||
from roledesk.config import Config
|
||||
from roledesk.jobs import extract
|
||||
from roledesk.storage import Store
|
||||
from app.config import Config
|
||||
from app.jobs import extract
|
||||
from app.storage import Store
|
||||
|
||||
|
||||
def posting(source_id: str, title: str = "Backend Engineer", **raw: object) -> Item:
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
from desk.models import Item # noqa: E402
|
||||
from plugins.ats import ATSSource # noqa: E402
|
||||
from roledesk.jobs import pull # noqa: E402
|
||||
from roledesk.storage import Store # noqa: E402
|
||||
from app.jobs import pull # noqa: E402
|
||||
from app.storage import Store # noqa: E402
|
||||
|
||||
|
||||
class FakeConfig:
|
||||
|
||||
+5
-5
@@ -19,10 +19,10 @@ if str(ROOT) not in sys.path:
|
||||
from desk.models import Item # noqa: E402
|
||||
from pipeline import FINAL, TASKS, JobQueue, Jobs, RunContext # noqa: E402
|
||||
from plugins.ats import ATSSource # noqa: E402
|
||||
from roledesk.config import AgentSeed, Config # noqa: E402
|
||||
from roledesk.jobs import cascade, embed, score # noqa: E402
|
||||
from roledesk.models import Candidate, Gate, Weights # noqa: E402
|
||||
from roledesk.storage import Store # noqa: E402
|
||||
from app.config import AgentSeed, Config # noqa: E402
|
||||
from app.jobs import cascade, embed, score # noqa: E402
|
||||
from app.models import Candidate, Gate, Weights # noqa: E402
|
||||
from app.storage import Store # noqa: E402
|
||||
|
||||
NOW = datetime(2026, 9, 23, 9, 0, tzinfo=UTC)
|
||||
|
||||
@@ -264,7 +264,7 @@ def test_starter_agents_are_imported_once(store: Store, tmp_path: Path) -> None:
|
||||
|
||||
|
||||
def test_the_shipped_starter_agents_validate() -> None:
|
||||
from roledesk import config as config_mod
|
||||
from app import config as config_mod
|
||||
|
||||
names = [a.name for a in config_mod.load(ROOT / "roles.yaml").agents]
|
||||
assert names == ["Berlin backend", "Remote EU stretch"]
|
||||
|
||||
@@ -11,8 +11,8 @@ import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from desk.models import Item
|
||||
from roledesk.models import Application, company_key, place_key, title_key
|
||||
from roledesk.storage import LATEST, Store
|
||||
from app.models import Application, company_key, place_key, title_key
|
||||
from app.storage import LATEST, Store
|
||||
|
||||
|
||||
class Clock:
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from desk.models import Item
|
||||
from roledesk.storage import Store
|
||||
from roledesk.web.app import create_app
|
||||
from app.storage import Store
|
||||
from app.web.app import create_app
|
||||
|
||||
|
||||
class Clock:
|
||||
|
||||
Reference in new issue
Block a user