Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
999cabe
updated server models for all responses
shreddd Jul 18, 2025
14cd2cd
relative import
shreddd Jul 18, 2025
e9d1277
Add testing setup
shreddd Jul 19, 2025
eae2bb3
ruff
shreddd Jul 19, 2025
d06765e
Merge branch 'main' into pydantic-server
shreddd Jul 19, 2025
16066fa
Update ci and skip failing tests
shreddd Jul 19, 2025
68f02de
cleanup
shreddd Jul 19, 2025
b8a4c3e
Merge branch 'main' into pydantic-server
eecavanna Jul 20, 2025
75320c7
Use standard `TestClient` instead of transitive `requests` package
eecavanna Jul 20, 2025
084c978
Update GHA workflow to ingest data into `bertron_test` database
eecavanna Jul 20, 2025
2589b52
Omit `-it` options from `docker compose run` in GHA workflow
eecavanna Jul 20, 2025
f02d6d7
Temporarily add "known passing" test to facilitate debugging GHA
eecavanna Jul 20, 2025
2d6cb43
Update ingester to log the database name
eecavanna Jul 20, 2025
a6e0bac
Remove duplicate test used for debugging
eecavanna Jul 20, 2025
e7a73db
Patch the config object via both `import` paths
eecavanna Jul 20, 2025
19c9cfd
Clarify comment
eecavanna Jul 20, 2025
39ed799
Convert `pytest` into a `dev-dependency`
eecavanna Jul 20, 2025
69341cc
Convert `httpx` into non-dev `dependency` because ingester imports it
eecavanna Jul 20, 2025
a6cab92
Refactor response type hints to get more validation from IDE
eecavanna Jul 20, 2025
ed03081
Fix entity id with `/`
shreddd Jul 22, 2025
c3db2bf
Validate Entity on ingest;
shreddd Jul 22, 2025
a016e86
update to use Entity object in ingest
shreddd Jul 22, 2025
039ed63
add ingest-test target to simplify testing
shreddd Jul 22, 2025
07c53be
Fix projection responses
shreddd Jul 22, 2025
70787b8
Update docker-compose.yml
shreddd Jul 22, 2025
7463251
comment
shreddd Jul 22, 2025
fe0e47b
ruff updates
shreddd Jul 22, 2025
6676ae8
remove unused Dict
shreddd Jul 22, 2025
c759e8e
Omit `.venv` folder from volume mount to avoid host-guest interference
eecavanna Jul 22, 2025
8241e8b
Update CONTRIBUTING.md
shreddd Jul 22, 2025
89433de
Relocate model to `models.py`
eecavanna Jul 22, 2025
5fcbce1
Merge branch 'pydantic-server' of https://github.com/ber-data/bertron…
eecavanna Jul 22, 2025
264aa54
Use `ruff` to reformat Python source files (to resolve GHA failure)
eecavanna Jul 22, 2025
c757a87
Remove commented-out command for running ingest directly
eecavanna Jul 22, 2025
98e0a82
Resolve type ambiguities in ingest script
eecavanna Jul 22, 2025
da01ccb
Combine two `startswith` calls into one using tuple syntax
eecavanna Jul 22, 2025
b610001
Clarify comment about what function does
eecavanna Jul 22, 2025
caf62e2
Add doctest and configure pytest to run it
eecavanna Jul 22, 2025
b631d10
Use `ruff` to reformat Python module (to resolve GHA failure)
eecavanna Jul 22, 2025
35b1075
Re-indent command to reflect abstraction layers
eecavanna Jul 22, 2025
8022e99
Run ingest script automatically via pytest fixture
eecavanna Jul 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@

# Omit Python cache files.
__pycache__/

# Ignore pytest cache files.
.pytest_cache/

# Ignore ruff cache files.
.ruff_cache/
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Check formatting
run: uv run ruff format --check -- src/

- name: Linting
- name: Lint
run: uv run ruff check -- src/

# Note: This spins up containers running the default services.
Expand All @@ -47,8 +47,8 @@ jobs:
- name: Spin up Docker Compose stack in background
run: docker compose up --detach

# Note: The `--exit-code-from test` option applies the exit code of the `test` container
# to the `docker compose` process, so that the GHA step fails if tests fail.
# Note: The `--exit-code-from test` option applies the exit code of the `ingest` container
# to the `docker compose` process, so that the GHA step fails if ingest fails.
# Reference: https://docs.docker.com/reference/cli/docker/compose/up/
- name: Spin up `test` container
run: docker compose up --exit-code-from test test
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ __pycache__

# Top-level environment configuration file.
/.env

# Ignore pytest cache files.
/.pytest_cache/

# Ignore ruff cache files.
/.ruff_cache/

# Ignore Vite files.
/.vite/
44 changes: 43 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ to make sure the Python virtual environment has the updated dependencies.

## Spin up container-based development environment

### Start the server
This repository includes a container-based development environment. If you have Docker installed, you can spin up that development environment by running:

```sh
Expand All @@ -76,4 +77,45 @@ docker compose up --detach

Once that's up and running, you can access the API at: http://localhost:8000

Also, you can access the MongoDB server at: `localhost:27017` (its admin credentials are in `docker-compose.yml`)
Also, you can access the MongoDB server at: `localhost:27017` (its admin credentials are in `docker-compose.yml`)

### Run Ingest
To populate the database with data run
```sh
docker compose run --volume /path/to/data:/data --rm ingest \
uv run --active \
python /app/mongodb/ingest_data.py \
--mongo-uri "mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}" \
--input /data --clean
```
(See `docker-compose.yml` for details)

Or if you want to use data in tests/data simply use:
```sh
docker compose up ingest
```

### Run Tests

Run the tests:

```sh
docker compose up test
```

<details>
<summary>Show/hide FAQ about the ingest script's role in testing</summary>

Note: The test suite includes a fixture, named `seeded_db`, that will invoke the ingest script automatically before each test that specifies that fixture as a dependency.

```py
def test_foo(seeded_db):
# The ingest script will be invoked automatically before this test runs.
pass

def test_foo()
# The ingest script will _not_ be invoked automatically before this test runs.
pass
```

</details>
17 changes: 16 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,19 @@ COPY . /app

# Run the FastAPI development server on port 8000, accepting HTTP requests from any host.
# Reference: https://fastapi.tiangolo.com/deployment/manually/
CMD [ "uv", "run", "fastapi", "dev", "--host", "0.0.0.0", "/app/src/server.py" ]
CMD [ "uv", "run", "fastapi", "dev", "--host", "0.0.0.0", "/app/src/server.py" ]

# ────────────────────────────────────────────────────────────────────────────┐
FROM development AS test
# ────────────────────────────────────────────────────────────────────────────┘

# Create a local virtual environment directory
# This is necessary for keeping the test environment isolated from
# running server environment in /app/.venv
RUN mkdir -p /app_venv
ENV VIRTUAL_ENV="/app_venv"

# This target inherits from development and is used for running tests
# No additional setup needed as development already has dev dependencies
# --active flag ensures that the local virtual environment is used
CMD [ "uv", "run", "--active", "pytest", "-v" ]
Loading