Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add core_version to server api query #126

Merged
merged 6 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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