Skip to content

Commit

Permalink
Improve checking if first party deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Dec 6, 2022
1 parent 2b48d0f commit ac2a718
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/bioregistry/app/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def web(
app = get_app(
manager=manager,
config=config,
first_party=registry is None
and metaregistry is None
and collections is None
and contexts is None,
)
run_app(
app=app,
Expand Down
17 changes: 8 additions & 9 deletions src/bioregistry/app/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@


def get_app(
manager: Optional[Manager] = None, config: Union[None, str, Path, Mapping[str, Any]] = None
manager: Optional[Manager] = None,
config: Union[None, str, Path, Mapping[str, Any]] = None,
first_party: bool = True,
) -> Flask:
"""Prepare the flask application.
:param manager: A pre-configured manager. If none given, uses the default manager.
:param config: Additional configuration to be passed to the flask application. See below.
:param first_party: Set to true if deploying the "canonical" bioregistry instance
:returns: An instantiated flask application
:raises ValueError: if there's an issue with the configuration's integrity
"""
Expand All @@ -109,13 +112,9 @@ def get_app(
app.config.setdefault("METAREGISTRY_VERSION", version.get_version())
app.config.setdefault("METAREGISTRY_EXAMPLE_PREFIX", "chebi")
app.config.setdefault("METAREGISTRY_EXAMPLE_IDENTIFIER", "138488")
app.config.setdefault("METAREGISTRY_FIRST_PARTY", first_party)

if manager is None:
manager = resource_manager.manager
app.config.setdefault("METAREGISTRY_FIRST_PARTY", True)
else:
app.config.setdefault("METAREGISTRY_FIRST_PARTY", False)
app.manager = manager
app.manager = manager or resource_manager.manager

example_prefix = app.config["METAREGISTRY_EXAMPLE_PREFIX"]
resource = app.manager.registry.get(example_prefix)
Expand Down Expand Up @@ -143,12 +142,12 @@ def get_app(
"url": "https://github.com/biopragmatics/bioregistry/blob/main/LICENSE",
},
},
"host": manager.base_url,
"host": app.manager.base_url,
"tags": [
{
"name": "collections",
"externalDocs": {
"url": f"{manager.base_url}/collection/",
"url": f"{app.manager.base_url}/collection/",
},
},
],
Expand Down
5 changes: 4 additions & 1 deletion src/bioregistry/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@
CURIE_VALIDATION_DATA_PATH = CURIE_VALIDATION.joinpath("data.tsv")
CURIE_VALIDATION_SVG_PATH = CURIE_VALIDATION.joinpath("results.svg")

BIOREGISTRY_DEFAULT_BASE_URL = "https://bioregistry.io"
#: The URL of the remote Bioregistry site
BIOREGISTRY_REMOTE_URL = pystow.get_config("bioregistry", "url") or "https://bioregistry.io"
BIOREGISTRY_REMOTE_URL = pystow.get_config(
"bioregistry", "url", default=BIOREGISTRY_DEFAULT_BASE_URL
)

#: Resolution is broken on identifiers.org for the following
IDOT_BROKEN = {
Expand Down

0 comments on commit ac2a718

Please sign in to comment.