Skip to content

Commit

Permalink
Merge branch 'main' into add-helm
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph authored Dec 16, 2024
2 parents 5f3d646 + 9f8e11a commit fca118b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ Write the date in place of the "Unreleased" in the case a new version is release

# Changelog

## 2024-12-13
## Unreleased

### Added

- Added a Helm chart with deployable default configuration
- `docker-compose.yml` now uses the healthcheck endpoint `/healthz`
- Added Helm chart with deployable default configuration

## 2024-12-09

Expand Down
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ services:
ports:
- 8000:8000
restart: unless-stopped
healthcheck:
test: curl --fail http://localhost:8000/healthz || exit 1
interval: 60s
timeout: 10s
retries: 3
start_period: 30s

# Below we additionally configure monitoring with Prometheus and Grafana.
# This is optional; it is not required for Tiled to function.
Expand Down
31 changes: 31 additions & 0 deletions tiled/_tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,34 @@ async def test_constraints_on_parameter_and_num(a, assets):
)
],
)


@pytest.mark.asyncio
async def test_init_db_logging(tmpdir, caplog):
config = {
"database": {
"uri": "sqlite+aiosqlite://", # in-memory
},
"trees": [
{
"tree": "catalog",
"path": "/",
"args": {
"uri": f"sqlite+aiosqlite:///{tmpdir}/catalog.db",
"writable_storage": str(tmpdir / "data"),
"init_if_not_exists": True,
},
},
],
}
# Issue 721 notes that the logging of the subprocess that creates
# a database logs normal things to error. This test looks at the log
# and fails if an error log happens. This could catch anything that is
# an error during the app build.
import logging

with caplog.at_level(logging.INFO):
app = build_app_from_config(config)
for record in caplog.records:
assert record.levelname != "ERROR", f"Error found creating app {record.msg}"
assert app
4 changes: 2 additions & 2 deletions tiled/catalog/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,8 @@ def from_uri(
# Capture stdout and stderr from the subprocess and write to logging
stdout = process.stdout.decode()
stderr = process.stderr.decode()
logging.info(f"Subprocess stdout: {stdout}")
logging.error(f"Subprocess stderr: {stderr}")
logger.info(f"Subprocess stdout: {stdout}")
logger.info(f"Subprocess stderr: {stderr}")

parsed_url = make_url(uri)
if (parsed_url.get_dialect().name == "sqlite") and (
Expand Down
17 changes: 17 additions & 0 deletions tiled/commandline/_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def serve_directory(
adapters_by_mimetype=adapters_by_mimetype,
)
if verbose:
from tiled.catalog.adapter import logger as catalog_logger

catalog_logger.addHandler(StreamHandler())
catalog_logger.setLevel("INFO")
register_logger.addHandler(StreamHandler())
register_logger.setLevel("INFO")
# Set the API key manually here, rather than letting the server do it,
Expand Down Expand Up @@ -345,6 +349,12 @@ def serve_catalog(
log_timestamps: bool = typer.Option(
False, help="Include timestamps in log output."
),
verbose: bool = typer.Option(
False,
"--verbose",
"-v",
help=("Log details of catalog creation."),
),
):
"Serve a catalog."
import urllib.parse
Expand Down Expand Up @@ -418,6 +428,13 @@ def serve_catalog(
err=True,
)
raise typer.Abort()
elif verbose:
from logging import StreamHandler

from tiled.catalog.adapter import logger as catalog_logger

catalog_logger.addHandler(StreamHandler())
catalog_logger.setLevel("INFO")

if write is None:
typer.echo(
Expand Down

0 comments on commit fca118b

Please sign in to comment.