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

feat: send client version to server #267

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
5 changes: 3 additions & 2 deletions diracx-client/src/diracx/client/_client.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any
from typing_extensions import Self

from azure.core import PipelineClient
from azure.core.pipeline import policies
Expand Down Expand Up @@ -112,7 +113,7 @@ def send_request(
def close(self) -> None:
self._client.close()

def __enter__(self) -> "Dirac":
def __enter__(self) -> Self:
self._client.__enter__()
return self

Expand Down
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/_configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
15 changes: 15 additions & 0 deletions diracx-client/src/diracx/client/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations

from datetime import datetime, timezone
from importlib.metadata import PackageNotFoundError, distribution
import json
import jwt
import requests
Expand Down Expand Up @@ -148,6 +149,20 @@
# Get .well-known configuration
openid_configuration = get_openid_configuration(self._endpoint, verify=verify)

try:
self.client_version = distribution("diracx").version
except PackageNotFoundError:
try:
self.client_version = distribution("diracx-client").version
except PackageNotFoundError:
print("Error while getting client version")
self.client_version = "Unknown"

Check warning on line 159 in diracx-client/src/diracx/client/_patch.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/_patch.py#L152-L159

Added lines #L152 - L159 were not covered by tests

# Setting default headers
kwargs.setdefault("base_headers", {})[

Check warning on line 162 in diracx-client/src/diracx/client/_patch.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/_patch.py#L162

Added line #L162 was not covered by tests
"DiracX-Client-Version"
] = self.client_version

# Initialize Dirac with a Dirac-specific token credential policy
super().__init__(
endpoint=self._endpoint,
Expand Down
2 changes: 2 additions & 0 deletions diracx-client/src/diracx/client/_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
# context otherwise.
_LOGGER.critical("Wasn't XML not JSON, failing")
raise DeserializationError("XML is invalid") from err
elif content_type.startswith("text/"):
return data_as_str

Check warning on line 150 in diracx-client/src/diracx/client/_serialization.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/_serialization.py#L149-L150

Added lines #L149 - L150 were not covered by tests
raise DeserializationError(
"Cannot deserialize content-type: {}".format(content_type)
)
Expand Down
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/_vendor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/aio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
5 changes: 3 additions & 2 deletions diracx-client/src/diracx/client/aio/_client.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any, Awaitable
from typing_extensions import Self

Check warning on line 9 in diracx-client/src/diracx/client/aio/_client.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/aio/_client.py#L9

Added line #L9 was not covered by tests

from azure.core import AsyncPipelineClient
from azure.core.pipeline import policies
Expand Down Expand Up @@ -112,7 +113,7 @@
async def close(self) -> None:
await self._client.close()

async def __aenter__(self) -> "Dirac":
async def __aenter__(self) -> Self:

Check warning on line 116 in diracx-client/src/diracx/client/aio/_client.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/aio/_client.py#L116

Added line #L116 was not covered by tests
await self._client.__aenter__()
return self

Expand Down
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/aio/_configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
15 changes: 15 additions & 0 deletions diracx-client/src/diracx/client/aio/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
"""
from importlib.metadata import PackageNotFoundError, distribution

Check warning on line 9 in diracx-client/src/diracx/client/aio/_patch.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/aio/_patch.py#L9

Added line #L9 was not covered by tests
import json
from types import TracebackType
from pathlib import Path
Expand Down Expand Up @@ -163,6 +164,20 @@
# Get .well-known configuration
openid_configuration = get_openid_configuration(self._endpoint, verify=verify)

try:
self.client_version = distribution("diracx").version
except PackageNotFoundError:
try:
self.client_version = distribution("diracx-client").version
except PackageNotFoundError:
print("Error while getting client version")
self.client_version = "Unknown"

Check warning on line 174 in diracx-client/src/diracx/client/aio/_patch.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/aio/_patch.py#L167-L174

Added lines #L167 - L174 were not covered by tests

# Setting default headers
kwargs.setdefault("base_headers", {})[

Check warning on line 177 in diracx-client/src/diracx/client/aio/_patch.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/aio/_patch.py#L177

Added line #L177 was not covered by tests
"DiracX-Client-Version"
] = self.client_version

# Initialize Dirac with a Dirac-specific token credential policy
super().__init__(
endpoint=self._endpoint,
Expand Down
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/aio/_vendor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion diracx-client/src/diracx/client/aio/operations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.13.19)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/python@6.15.0)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Loading