Skip to content

Commit f85e180

Browse files
committed
type, lint, test fixes
1 parent 3bcf803 commit f85e180

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

graphistry/Plottable.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,4 +790,3 @@ def transform_umap(self, df: pd.DataFrame,
790790
umap_transform_kwargs: Dict[str, Any] = {}
791791
) -> Union[Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame], 'Plottable']:
792792
...
793-

graphistry/PlotterBase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,10 +1693,10 @@ def plot(
16931693
assert uploader is not None
16941694
if skip_upload:
16951695
return uploader
1696-
uploader.token = self._session.api_token # type: ignore[assignment]
1696+
uploader.token = self._session.api_token # type: ignore[assignment]
16971697
uploader.post(as_files=as_files, memoize=memoize, validate=validate, erase_files_on_fail=erase_files_on_fail)
16981698
uploader.maybe_post_share_link(self)
1699-
info: DatasetInfo = {
1699+
info = {
17001700
'name': uploader.dataset_id,
17011701
'type': 'arrow',
17021702
'viztoken': str(uuid.uuid4())

graphistry/arrow_uploader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def sso_login(self, org_name: Optional[str] = None, idp_name: Optional[str] = No
331331
logger.debug("@ArrowUploader.sso_login, out.text: %s", out.text)
332332
json_response = out.json()
333333
logger.debug("@ArrowUploader.sso_login, json_response: %s", json_response)
334-
self.token = None # type: ignore[assignment]
334+
self.token = None # type: ignore[assignment]
335335
if not ('status' in json_response):
336336
raise Exception(out.text)
337337
else:

graphistry/client_session.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self) -> None:
5656
self.personal_key_secret: Optional[str] = None
5757

5858
# NOTE: Still used as a global, perhaps use a session pattern
59-
self.encode_textual_batch_size: Optional[int] = None # encode_textual.batch_size
59+
self.encode_textual_batch_size: Optional[int] = None # encode_textual.batch_size
6060

6161
# TODO: Migrate to a pattern like Kusto or Spanner
6262
self.bolt_driver: Optional[Any] = None
@@ -87,6 +87,9 @@ def _viz_url(self, info: DatasetInfo, url_params: Dict[str, Any]) -> str:
8787

8888
def certificate_validation(self, value: Optional[bool] = None) -> bool:
8989
...
90+
91+
def api_token(self, value: Optional[str] = None) -> Optional[str]:
92+
...
9093

9194

9295
@deprecated("Use the session pattern instead")
@@ -98,9 +101,11 @@ def use_global_session() -> ClientSession:
98101
T = TypeVar("T")
99102

100103
@overload
101-
def get_from_env(name: str, expected_type: Type[T]) -> Optional[T]: ...
104+
def get_from_env(name: str, expected_type: Type[T]) -> Optional[T]:
105+
...
102106
@overload # when a *non-None* default is supplied, return is not Optional
103-
def get_from_env(name: str, expected_type: Type[T], default: T) -> T: ...
107+
def get_from_env(name: str, expected_type: Type[T], default: T) -> T:
108+
...
104109

105110
def get_from_env(
106111
name: str,

graphistry/plugins/kustograph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
# NOTE: Cooperative Mixin initialization passes args and kwargs along
3333
super().__init__(*args, **kwargs)
3434

35-
session = kwargs.get('pygraphistry_session', {}).get('_session', None)
35+
session = getattr(kwargs.get('pygraphistry_session', {}), '_session', None)
3636
self._kusto_session = session.kusto if isinstance(session, ClientSession) else KustoSession()
3737

3838
def from_kusto_client(self, client: KustoClient, database: str) -> 'KustoGraph':
@@ -65,7 +65,7 @@ def kusto_connect(self, config: Optional[KustoConfig] = None) -> 'KustoGraph':
6565
self._kusto_session.client = None
6666
self._kusto_session.database = None
6767

68-
_ = self.kusto_client # trigger initialization
68+
_ = self.kusto_client # trigger initialization
6969
return self
7070

7171
@property

graphistry/plugins/spannergraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(
3737
# NOTE: Cooperative Mixin initialization passes args and kwargs along
3838
super().__init__(*args, **kwargs)
3939

40-
session = kwargs.get('pygraphistry_session', {}).get('_session', None)
40+
session = getattr(kwargs.get('pygraphistry_session', {}), '_session', None)
4141
self._spanner_session = session.spanner if isinstance(session, ClientSession) else SpannerSession()
4242

4343
def from_spanner_client(self, client: Connection, database: str) -> "SpannerGraph":
@@ -52,7 +52,7 @@ def spanner_connect(self, config: Optional[SpannerConfig] = None) -> "SpannerGra
5252
self._spanner_session.client = None
5353
self._spanner_session.database = None
5454

55-
_ = self.spanner_client # trigger initialization
55+
_ = self.spanner_client # trigger initialization
5656
return self
5757

5858
@property

graphistry/pygraphistry.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
_client_mode_enabled = False
4141
_is_client_mode_warned = False
42-
PyGraphistry: "SessionManagerProtocol" = None # type: ignore[assignment]
42+
PyGraphistry: "PyGraphistrySession" = None # type: ignore[assignment]
4343

4444

4545
class PyGraphistrySession(SessionManagerProtocol):
@@ -353,6 +353,7 @@ def refresh(self, token: Optional[str] = None, fail_silent: bool = False) -> Opt
353353
if not fail_silent:
354354
util.error("Failed to refresh token: %s" % str(e))
355355
raise e
356+
return None
356357

357358
def verify_token(self, token: Optional[str] = None, fail_silent: bool = False) -> bool:
358359
"""Return True iff current or provided token is still valid"""
@@ -2171,7 +2172,7 @@ def _viz_url(self, info: DatasetInfo, url_params: Dict[str, Any]) -> str:
21712172
info["name"],
21722173
info["type"],
21732174
info["viztoken"],
2174-
self._tag,
2175+
self._session._tag,
21752176
splash_time,
21762177
extra,
21772178
)

graphistry/tests/test_umap_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
import gc
88
import graphistry
9+
from graphistry.pygraphistry import PyGraphistry
910
import os
1011
import logging
1112
import numpy as np
1213
import pandas as pd
13-
from graphistry.config import config
1414
from graphistry.feature_utils import remove_internal_namespace_if_present
1515
from graphistry.tests.test_feature_utils import (
1616
ndf_reddit,
@@ -737,11 +737,11 @@ def setup_method(self, method: Any) -> None:
737737

738738
@classmethod
739739
def setup_class(cls: Any) -> None:
740-
config.set('encode_textual.batch_size', 8)
740+
PyGraphistry._session.encode_textual_batch_size = 8
741741

742742
@classmethod
743743
def teardown_class(cls: Any) -> None:
744-
config.unset('encode_textual.batch_size')
744+
PyGraphistry._session.encode_textual_batch_size = None
745745

746746
@pytest.mark.skipif(
747747
not has_dependancy or not has_cuml,

0 commit comments

Comments
 (0)