Skip to content

Commit

Permalink
Merge pull request #126 from PrefectHQ/core-version-query
Browse files Browse the repository at this point in the history
Add `core_version` to server api query
  • Loading branch information
cicdw committed Nov 11, 2020
2 parents b8122ef + dff515e commit 084501a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changes/pr126.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enhancement:
- "Add the Prefect Core version to the api query - [#126](https://github.com/PrefectHQ/server/pull/126)"
2 changes: 2 additions & 0 deletions src/prefect_server/graphql/query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from typing import Any, Dict, List

import prefect
import prefect_server
from prefect.engine import state
from prefect_server.utilities import graphql
Expand Down Expand Up @@ -44,5 +45,6 @@ def resolve_reference(parent: Any, info):
"backend": "SERVER",
"mode": "normal",
"version": os.getenv("PREFECT_SERVER_VERSION", prefect_server.__version__),
"core_version": os.getenv("PREFECT_CORE_VERSION", prefect.__version__),
"release_timestamp": os.getenv("RELEASE_TIMESTAMP"),
}
1 change: 1 addition & 0 deletions src/prefect_server/graphql/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ type api_info {
backend: String
mode: String
version: String
core_version: String
release_timestamp: String
}

Expand Down
15 changes: 15 additions & 0 deletions tests/graphql/queries/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
backend
mode
version
core_version
release_timestamp
}
}
Expand All @@ -25,6 +26,20 @@ async def test_mode(run_query):
assert result.data.api.mode == "normal"


async def test_core_version_uses_env_var(run_query, monkeypatch):
monkeypatch.setenv("PREFECT_CORE_VERSION", "core-version")
result = await run_query(query=QUERY)
assert result.data.api.core_version == "core-version"


async def test_core_version_uses_dunder_if_no_env_var(run_query, monkeypatch):
if "PREFECT_CORE_VERSION" in os.environ:
monkeypatch.delenv("PREFECT_CORE_VERSION")

result = await run_query(query=QUERY)
assert result.data.api.core_version == prefect.__version__


async def test_server_version_picks_up_dunder_version_if_no_server_env_var(
run_query, monkeypatch
):
Expand Down

0 comments on commit 084501a

Please sign in to comment.