generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/117-install-assets
- Loading branch information
Showing
16 changed files
with
175 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/sh | ||
|
||
# This script builds the public documentation for this repository. | ||
# | ||
# Usage: build_docs.sh | ||
# Requires: npx | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
OUT=${1:-_site} | ||
VERSION=${VERSION:-$(python -c "from recordlinker._version import __version__; print(f'v{__version__}');")} | ||
SITE_NAME="RecordLinker Documentation (${VERSION})" | ||
|
||
SITE_NAME=${SITE_NAME} mkdocs build --config-file docs/mkdocs.yml -d "../${OUT}" | ||
python -m recordlinker.utils.openapi_schema > ${OUT}/openapi.json | ||
npx @redocly/cli build-docs -o "${OUT}/api-docs.html" "${OUT}/openapi.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import json | ||
import pathlib | ||
|
||
|
||
def project_root() -> pathlib.Path: | ||
""" | ||
Returns the path to the project root directory. | ||
""" | ||
root = pathlib.Path(__file__).resolve() | ||
while root.name != "recordlinker": | ||
if root.parent == root: | ||
raise FileNotFoundError("recordlinker project root not found.") | ||
root = root.parent | ||
return root | ||
|
||
|
||
def read_json(path: str) -> dict: | ||
""" | ||
Loads a JSON file. | ||
""" | ||
if not pathlib.Path(path).is_absolute(): | ||
# if path is relative, append to the project root | ||
path = str(pathlib.Path(project_root(), path)) | ||
with open(path, "r") as fobj: | ||
return json.load(fobj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class MockTracer: | ||
""" | ||
A no-op OTel tracer that can be used in place of a real tracer. This is useful | ||
for situations where users decide to not install the otelemetry package. | ||
""" | ||
|
||
def start_as_current_span(self, name, **kwargs): | ||
"""Returns a no-op span""" | ||
return self | ||
|
||
def __enter__(self): | ||
"""No-op for context manager entry""" | ||
pass | ||
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
"""No-op for context manager exit""" | ||
pass | ||
|
||
def start_span(self, name, **kwargs): | ||
"""Returns a no-op span""" | ||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
recordlinker.openapi_schema | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
This module exports the OpenAPI schema for the Record Linker service. | ||
""" | ||
|
||
import json | ||
import sys | ||
import typing | ||
|
||
from fastapi.openapi.utils import get_openapi | ||
|
||
from recordlinker import main | ||
|
||
|
||
def export_json(file: typing.TextIO): | ||
""" | ||
Export the OpenAPI schema to a JSON file. | ||
""" | ||
json.dump( | ||
get_openapi( | ||
title=main.app.title, | ||
version=main.app.version, | ||
openapi_version=main.app.openapi_version, | ||
description=main.app.description, | ||
routes=main.app.routes, | ||
license_info=main.app.license_info, | ||
contact=main.app.contact, | ||
), | ||
file, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
export_json(sys.stdout) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from recordlinker.utils import mock as utils | ||
|
||
|
||
class TestMockTracer: | ||
def test_start_span(self): | ||
tracer = utils.MockTracer() | ||
with tracer.start_span("test_span") as span: | ||
assert span is None | ||
|
||
def test_start_as_current_span(self): | ||
tracer = utils.MockTracer() | ||
with tracer.start_as_current_span("test.span") as span: | ||
assert span is None |
Oops, something went wrong.