Skip to content

Commit ec79402

Browse files
authored
Merge pull request #310 from VariantEffect/maintenance/bencap/274/deps
Refresh Dependencies for High Severity Dependabot Alerts
2 parents 0801794 + f8b3bec commit ec79402

File tree

8 files changed

+1253
-1069
lines changed

8 files changed

+1253
-1069
lines changed

.github/workflows/run-tests-on-push.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- run: pip install --upgrade pip
1919
- run: pip install poetry
2020
- run: poetry install --with dev --extras server
21-
- run: poetry run pytest tests/ --show-capture=stdout
21+
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
2222

2323
run-tests-3_10:
2424
runs-on: ubuntu-latest
@@ -32,7 +32,7 @@ jobs:
3232
- run: pip install --upgrade pip
3333
- run: pip install poetry
3434
- run: poetry install --with dev --extras server
35-
- run: poetry run pytest tests/ --show-capture=stdout
35+
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
3636

3737
run-tests-3_11:
3838
runs-on: ubuntu-latest
@@ -46,7 +46,7 @@ jobs:
4646
- run: pip install --upgrade pip
4747
- run: pip install poetry
4848
- run: poetry install --with dev --extras server
49-
- run: poetry run pytest tests/ --show-capture=stdout
49+
- run: poetry run pytest tests/ --show-capture=stdout --cov=src
5050

5151
run-mypy-3_10:
5252
runs-on: ubuntu-latest

poetry.lock

Lines changed: 1144 additions & 1025 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,36 @@ python = "^3.9"
2626

2727
fqfa = "~1.3.0"
2828
pyhumps = "~3.8.0"
29+
pyyaml = "~5.1"
2930
IDUtils = "~1.2.0"
3031
mavehgvs = "~0.6.0"
3132
eutils = "~0.6.0"
32-
hgvs = "~1.5.4"
33-
biocommons = "~0.0.0"
34-
cdot = "~0.2.21"
33+
email_validator = "~2.1.1"
3534
numpy = "~1.26"
3635
httpx = "~0.26.0"
3736
pandas = "~1.4.1"
3837
pydantic = "~1.10"
3938
python-dotenv = "~0.20.0"
4039
python-json-logger = "~2.0.7"
4140
SQLAlchemy = "~2.0.0"
42-
starlette = "~0.27.0"
43-
starlette-context = "^0.3.6"
4441

4542
# Optional dependencies for running this application as a server
4643
alembic = { version = "~1.7.6", optional = true }
4744
arq = { version = "~0.25.0", optional = true }
48-
authlib = { version = "~0.15.5", optional = true }
45+
authlib = { version = "~1.3.1", optional = true }
4946
boto3 = { version = "~1.34.97", optional = true }
50-
cryptography = { version = "~41.0.6", optional = true }
51-
email-validator = { version = "~2.1.1", optional = true }
47+
biocommons = { version = "~0.0.0", optional = true }
48+
cryptography = { version = "~43.0.1", optional = true }
49+
cdot = { version = "~0.2.21", optional = true }
5250
fastapi = { version = "~0.95.0", optional = true }
51+
hgvs = { version = "~1.5.4", optional = true }
5352
orcid = { version = "~1.0.3", optional = true }
5453
psycopg2 = { version = "~2.9.3", optional = true }
5554
python-jose = { extras = ["cryptography"], version = "~3.3.0", optional = true }
5655
python-multipart = { version = "~0.0.5", optional = true }
57-
requests = { version = "~2.31.0", optional = true }
56+
requests = { version = "~2.32.0", optional = true }
57+
starlette = { version = "~0.27.0", optional = true }
58+
starlette-context = { version = "^0.3.6", optional = true }
5859
slack-sdk = { version = "~3.21.3", optional = true }
5960
uvicorn = { extras = ["standard"], version = "*", optional = true }
6061
watchtower = { version = "~3.2.0", optional = true }
@@ -70,7 +71,8 @@ mypy = "~1.10.0"
7071
pre-commit = "*"
7172
jsonschema = "*"
7273
fakeredis = "~2.21.1"
73-
pytest = "~7.0.1"
74+
pytest = "~7.2.0"
75+
pytest-cov = "~5.0.0"
7476
pytest-postgresql = "~5.0.0"
7577
pytest-asyncio = "~0.23.5"
7678
pytest-socket = "~0.6.0"
@@ -84,7 +86,7 @@ SQLAlchemy = { extras = ["mypy"], version = "~2.0.0" }
8486

8587

8688
[tool.poetry.extras]
87-
server = ["alembic", "arq", "authlib", "boto3", "cryptography", "fastapi", "email-validator", "orcid", "psycopg2", "python-jose", "python-multipart", "requests", "slack-sdk", "uvicorn", "watchtower"]
89+
server = ["alembic", "arq", "authlib", "biocommons", "boto3", "cdot", "cryptography", "fastapi", "hgvs", "orcid", "psycopg2", "python-jose", "python-multipart", "requests", "starlette", "starlette-context", "slack-sdk", "uvicorn", "watchtower"]
8890

8991

9092
[tool.black]

src/mavedb/logging/__init__.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
import os
44
import sys
55

6-
from watchtower import CloudWatchLogHandler
7-
86
from .config import load_stock_config
97
from .filters import canonical_only
108
from .formatters import MavedbJsonFormatter
119

10+
WATCHTOWER_IMPORTED = False
11+
try:
12+
from watchtower import CloudWatchLogHandler
13+
14+
WATCHTOWER_IMPORTED = True
15+
except ModuleNotFoundError:
16+
pass
17+
1218
LOG_CONFIG = os.environ.get("LOG_CONFIG")
1319

1420

@@ -35,12 +41,14 @@ def configure():
3541
# Formatter and handler are un-configurable via file config.
3642
cw_is_enabled = False
3743
root_logger = logging.getLogger("root")
38-
for handler in root_logger.handlers:
39-
if isinstance(handler, CloudWatchLogHandler):
40-
handler.addFilter(canonical_only)
41-
handler.formatter = MavedbJsonFormatter()
4244

43-
cw_is_enabled = True
45+
if WATCHTOWER_IMPORTED:
46+
for handler in root_logger.handlers:
47+
if isinstance(handler, CloudWatchLogHandler):
48+
handler.addFilter(canonical_only)
49+
handler.formatter = MavedbJsonFormatter()
50+
51+
cw_is_enabled = True
4452

4553
if not cw_is_enabled:
4654
root_logger.info("CloudWatch log handler is not enabled. Canonical logs will only be emitted to stdout.")

src/mavedb/logging/configurations/default.yaml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ root:
99
propagate: true
1010
handlers:
1111
- console
12-
- watchtower
1312

1413
loggers:
1514
urllib3:
@@ -18,10 +17,6 @@ loggers:
1817
botocore:
1918
level: INFO
2019

21-
# HGVS emits a log line on startup, silence it.
22-
hgvs:
23-
level: WARNING
24-
2520
# To log all database queries, set this to INFO
2621
sqlalchemy:
2722
level: WARNING
@@ -35,19 +30,7 @@ handlers:
3530
stream: ext://sys.stdout
3631
formatter: json
3732

38-
watchtower:
39-
class: watchtower.CloudWatchLogHandler
40-
level: !coalesce
41-
- !LOG_LEVEL
42-
- INFO
43-
log_group_name: !CLOUD_WATCH_LOG_GROUP
44-
log_stream_name: "{machine_name}/{logger_name}/{strftime:%y-%m-%d}"
45-
send_interval: 10
46-
use_queues: !CLOUD_WATCH_USE_QUEUES
47-
create_log_group: True
48-
formatter: json
49-
5033
formatters:
5134
json:
52-
class: mavedb.logging.MavedbJsonFormatter
35+
class: pythonjsonlogger.jsonlogger.JsonFormatter
5336
format: "%(message)s"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
version: 1
2+
disable_existing_loggers: False
3+
4+
root:
5+
# Filtering of messages by level is done at the handler level by using NOTSET
6+
# on the root logger to emit everything. This lets us keep console output
7+
# readable while emitting verbose output to alternate handlers.
8+
level: NOTSET
9+
propagate: true
10+
handlers:
11+
- console
12+
- watchtower
13+
14+
loggers:
15+
urllib3:
16+
level: INFO
17+
18+
botocore:
19+
level: INFO
20+
21+
# HGVS emits a log line on startup, silence it.
22+
hgvs:
23+
level: WARNING
24+
25+
# To log all database queries, set this to INFO
26+
sqlalchemy:
27+
level: WARNING
28+
29+
handlers:
30+
console:
31+
class: logging.StreamHandler
32+
level: !coalesce
33+
- !LOG_LEVEL
34+
- INFO
35+
stream: ext://sys.stdout
36+
formatter: json
37+
38+
watchtower:
39+
class: watchtower.CloudWatchLogHandler
40+
level: !coalesce
41+
- !LOG_LEVEL
42+
- INFO
43+
log_group_name: !CLOUD_WATCH_LOG_GROUP
44+
log_stream_name: "{machine_name}/{logger_name}/{strftime:%y-%m-%d}"
45+
send_interval: 10
46+
use_queues: !CLOUD_WATCH_USE_QUEUES
47+
create_log_group: True
48+
formatter: json
49+
50+
formatters:
51+
json:
52+
class: mavedb.logging.MavedbJsonFormatter
53+
format: "%(message)s"

src/mavedb/routers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Import view models up front so any deferred forward references are resolved prior to OpenAPI spec generation.
2+
import mavedb.view_models

src/mavedb/view_models/score_set.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
DoiIdentifierCreate,
2323
SavedDoiIdentifier,
2424
)
25-
from mavedb.view_models.experiment import Experiment, SavedExperiment
2625
from mavedb.view_models.license import ShortLicense
2726
from mavedb.view_models.publication_identifier import (
2827
PublicationIdentifier,
@@ -136,7 +135,13 @@ def targets_need_labels_when_multiple_targets_exist(cls, field_value, values):
136135
if target.target_sequence and target.target_sequence.label is None:
137136
raise ValidationError(
138137
"Target sequence labels cannot be empty when multiple targets are defined.",
139-
custom_loc=["body", "targetGene", idx, "targetSequence", "label"],
138+
custom_loc=[
139+
"body",
140+
"targetGene",
141+
idx,
142+
"targetSequence",
143+
"label",
144+
],
140145
)
141146

142147
return field_value
@@ -155,7 +160,13 @@ def target_labels_are_unique(cls, field_value, values):
155160
# just one for now seems fine.
156161
raise ValidationError(
157162
"Target sequence labels cannot be duplicated.",
158-
custom_loc=["body", "targetGene", dup_indices[-1], "targetSequence", "label"],
163+
custom_loc=[
164+
"body",
165+
"targetGene",
166+
dup_indices[-1],
167+
"targetSequence",
168+
"label",
169+
],
159170
)
160171

161172
return field_value
@@ -312,7 +323,7 @@ class ShortScoreSet(BaseModel):
312323
published_date: Optional[date]
313324
replaces_id: Optional[int]
314325
num_variants: int
315-
experiment: Experiment
326+
experiment: "Experiment"
316327
primary_publication_identifiers: list[SavedPublicationIdentifier]
317328
secondary_publication_identifiers: list[SavedPublicationIdentifier]
318329
license: ShortLicense
@@ -380,7 +391,7 @@ def camelize_dataset_columns_keys(cls, value) -> dict:
380391
class ScoreSet(SavedScoreSet):
381392
"""Score set view model containing most properties visible to non-admin users, but no variant data."""
382393

383-
experiment: Experiment
394+
experiment: "Experiment"
384395
doi_identifiers: Sequence[DoiIdentifier]
385396
primary_publication_identifiers: Sequence[PublicationIdentifier]
386397
secondary_publication_identifiers: Sequence[PublicationIdentifier]
@@ -424,3 +435,9 @@ class ScoreSetPublicDump(SavedScoreSet):
424435
processing_errors: Optional[Dict]
425436
mapping_state: Optional[MappingState]
426437
mapping_errors: Optional[Dict]
438+
439+
440+
from mavedb.view_models.experiment import Experiment
441+
442+
ShortScoreSet.update_forward_refs()
443+
ScoreSet.update_forward_refs()

0 commit comments

Comments
 (0)