Skip to content

Commit

Permalink
Merge pull request #31 from openweathermap/fix/commits-from-main
Browse files Browse the repository at this point in the history
Fix/commits from main
  • Loading branch information
matveyvarg authored Jun 12, 2024
2 parents 93debf4 + b4849a2 commit ee96015
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions deker_server_adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ def get_by_primary_attributes(
response = self.client.get(
f"{self.collection_host}{url}",
)
if not response or response.status_code != STATUS_OK:
if not response or response.status_code not in [STATUS_OK, NOT_FOUND]:
raise DekerServerError(response, "Couldn't fetch array")
if response.status_code == NOT_FOUND:
return None
return self.__create_array_from_response(
response,
dict(
Expand Down Expand Up @@ -408,9 +410,12 @@ def get_by_id(
f"{self.collection_host}{url}",
)

if not response or response.status_code != STATUS_OK:
if not response or response.status_code not in [STATUS_OK, NOT_FOUND]:
raise DekerServerError(response, "Couldn't fetch array")

if response.status_code == NOT_FOUND:
return None

return self.__create_array_from_response(
response,
dict(
Expand Down
1 change: 1 addition & 0 deletions deker_server_adapters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ class Status(str, Enum):

MOVED = "exported"
UNMOVED = "exporting"
NORMAL = "normal"
3 changes: 2 additions & 1 deletion deker_server_adapters/utils/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from deker_server_adapters.errors import DekerServerError
from deker_server_adapters.models import Status
from deker_server_adapters.utils.hashing import get_hash_key, get_id_and_primary_attributes
from deker_server_adapters.utils.version import get_api_version


if TYPE_CHECKING:
Expand Down Expand Up @@ -78,7 +79,7 @@ def check_status(ctx: CTX, array: BaseArray) -> Status:
client: "HttpxClient" = ctx.extra["httpx_client"]
node = ctx.extra["hash_ring"].get_node(get_hash_key(array))
id_, _ = get_id_and_primary_attributes(array)
url = node.url / f"/cluster/collection/{array.collection}/array/by-id/{id_}/status"
url = node.url / f"{get_api_version()}/cluster/collection/{array.collection}/array/by-id/{id_}/status"
response = client.get(url.raw_url)

if not response or response.status_code != STATUS_OK:
Expand Down

0 comments on commit ee96015

Please sign in to comment.