Skip to content

Commit

Permalink
protect for missing endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bdpedigo committed Apr 3, 2024
1 parent 5b23a40 commit 2bbca71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
16 changes: 7 additions & 9 deletions caveclient/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,14 @@ def api_version(self):

def _get_version(self) -> Optional[Version]:
endpoint_mapping = self.default_url_mapping
url = self._endpoints["get_version"].format_map(endpoint_mapping)
url = self._endpoints.get("get_version", None).format_map(endpoint_mapping)
response = self.session.get(url)
# TODO none_on_404 is not a thing
response = handle_response(response, as_json=True, none_on_404=True)
# if response.status_code == 404: # server doesn't have this endpoint yet
# return None
# else:
# version_str = response.json()
# version = Version(version_str)
# return version
if response.status_code == 404: # server doesn't have this endpoint yet
return None
else:
version_str = handle_response(response, as_json=True)
version = Version(version_str)
return version

@property
def server_version(self) -> Optional[Version]:
Expand Down
5 changes: 1 addition & 4 deletions caveclient/chunkedgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import datetime
import json
import logging
from typing import Iterable, Optional, Tuple, Union
from typing import Iterable, Tuple, Union
from urllib.parse import urlencode

import networkx as nx
import numpy as np
import pandas as pd
import pytz
from packaging.version import Version

from .auth import AuthClient
from .base import (
Expand Down Expand Up @@ -200,8 +199,6 @@ def default_url_mapping(self):
def table_name(self):
return self._table_name



def _process_timestamp(self, timestamp):
"""Process timestamp with default logic"""
if timestamp is None:
Expand Down

0 comments on commit 2bbca71

Please sign in to comment.