Skip to content

Commit

Permalink
feat: dump OpenAPI YAML in python -m dotty.main (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Aug 29, 2024
1 parent bb00c13 commit 3744d9f
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 1,667 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fastapi = "*"
hgvs = "*"
pydantic-settings = "*"
uvicorn = "*"
pyyaml = "*"

[dev-packages]
black = "*"
Expand Down
1,880 changes: 250 additions & 1,630 deletions Pipfile.lock

Large diffs are not rendered by default.

13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,8 @@ $ seqrepo --root-directory $PWD load --namespace ncbi --instance-name seqrepo nc
$ rm -rf GRCh3?.zip ncbi_dataset
```

## Terraform Project Management
## Dump OpenAPI Schema

```
$ export GITHUB_OWNER=bihealth
$ export GITHUB_TOKEN=ghp_<thetoken>
$ cd utils/terraform
$ terraform init
$ terraform import github_repository.dotty dotty
$ terraform validate
$ terraform fmt
$ terraform plan
$ terraform apply
# python -m dotty.main > openapi.yaml
```
14 changes: 11 additions & 3 deletions dotty/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging
import sys
import typing
from contextlib import asynccontextmanager

import bioutils.assemblies
import hgvs.exceptions
import pydantic
import yaml
from fastapi import FastAPI, HTTPException

from dotty.config import settings
Expand Down Expand Up @@ -177,9 +179,11 @@ def _from_dict(assembly: str, dct: dict[str, typing.Any]) -> "Transcript":
id=dct["id"],
hgnc_id=f"HGNC:{dct['hgnc']}",
hgnc_symbol=dct["gene_name"],
alignments=[TanscriptAlignment._from_dict(assembly, dct["genome_builds"][assembly])]
if assembly in dct["genome_builds"]
else [],
alignments=(
[TanscriptAlignment._from_dict(assembly, dct["genome_builds"][assembly])]
if assembly in dct["genome_builds"]
else []
),
)


Expand Down Expand Up @@ -242,3 +246,7 @@ async def find_transcripts(hgnc_id: str, assembly: Assembly = Assembly.GRCH38) -

result.append(Transcript._from_dict(assembly.value, t))
return TranscriptResult(transcripts=result)


if __name__ == "__main__":
yaml.dump(app.openapi(), sys.stdout)
2 changes: 0 additions & 2 deletions utils/terraform/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion utils/terraform/.python-version

This file was deleted.

19 changes: 0 additions & 19 deletions utils/terraform/main.tf

This file was deleted.

1 change: 0 additions & 1 deletion utils/terraform/provider.tf

This file was deleted.

0 comments on commit 3744d9f

Please sign in to comment.