From 63e870a470f365f6249e2763afee794a2bdbc166 Mon Sep 17 00:00:00 2001 From: Brandon Kuczenski Date: Sun, 22 Sep 2024 23:28:30 -0700 Subject: [PATCH] 0.3.4 release for workshop - ditch make_tester() --- antelope_core/catalog/lc_catalog.py | 26 ++++++------------- .../providers/xdb_client/rest_client.py | 3 +++ setup.py | 4 ++- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/antelope_core/catalog/lc_catalog.py b/antelope_core/catalog/lc_catalog.py index 9910324..8c2377e 100644 --- a/antelope_core/catalog/lc_catalog.py +++ b/antelope_core/catalog/lc_catalog.py @@ -74,7 +74,7 @@ def download_file(self, url=None, md5sum=None, force=False, localize=True): @classmethod def make_tester(cls, **kwargs): """ - Sets a flag that tells the rootdir to be deleted when the catalog is garbage collected + This is no longer necessary; the same thing can be accomplished just by calling the constructor with no root. :param kwargs: :return: """ @@ -107,27 +107,17 @@ def _make_rootdir(self): if not os.path.exists(self._reference_qtys): copy2(REF_QTYS, self._reference_qtys) - def __init__(self, rootdir, _test=False, **kwargs): - self._test = _test - if self._test: + def __init__(self, rootdir=None, _test=False, **kwargs): + if rootdir is None or _test is True: + self._test = True self._rootdir = None else: + self._test = False self._rootdir = os.path.abspath(rootdir) self._make_rootdir() # this will be a git clone / fork;; clones reference quantities self._blackbook_client = None super(LcCatalog, self).__init__(self._rootdir, **kwargs) - def __del__(self): - """ - This is unreliable- temp directories tend to accumulate - :return: - """ - if self._blackbook_client: - self._blackbook_client.close() - # if self._test: # no longer need to do this - # # print('tryna delete %s' % self.root) - # rmtree(self.root, ignore_errors=True) - def save_local_changes(self): if self._test: logging.warning('Cannot save changes during tester operation') @@ -394,7 +384,7 @@ def _configure_blackbook_resources(self, resource_list, store=False, **kwargs): if exis.source == res.source: exis.archive.refresh_token(res.options['token']) else: - exis.source = res.source + exis._source = res.source exis.archive.refresh_auth(res.source, res.options['token']) for i in res.interfaces: if i not in exis.interfaces: @@ -424,10 +414,10 @@ def refresh_xdb_tokens(self, remote_origin=None): rtn.extend(self.refresh_xdb_tokens(r.init_args['blackbook_origin'])) return rtn - tok = self._blackbook_client.get_one(str, 'origins', remote_origin, 'token') + tok = self._blackbook_client.get_one(OAuthToken, 'origins', remote_origin, 'token') for res in self._resolver.resources: if res.init_args.get('blackbook_origin') == remote_origin: - res.init_args['token'] = tok + res.init_args['token'] = tok.access_token if res.archive is None: res.check(self) elif hasattr(res.archive, 'r'): diff --git a/antelope_core/providers/xdb_client/rest_client.py b/antelope_core/providers/xdb_client/rest_client.py index ac40da7..dafbc00 100644 --- a/antelope_core/providers/xdb_client/rest_client.py +++ b/antelope_core/providers/xdb_client/rest_client.py @@ -11,6 +11,7 @@ class OAuthToken(BaseModel): token_type: str access_token: str message: Optional[str] = None + expires_in: Optional[int] = None @property def auth(self): @@ -75,6 +76,8 @@ def set_token(self, token): self._token = token if token.message: print(token.message) + if token.expires_in: + print('token expires in %d s' % token.expires_in) elif isinstance(token, str): toks = token.split(' ') if len(toks) == 1: diff --git a/setup.py b/setup.py index 735e84b..3088c9b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = '0.3.4-pre' +VERSION = '0.3.4' requires = [ "synonym_dict>=0.2.4", @@ -14,6 +14,8 @@ # optional: pylzma """ Version History +0.3.4 2024-09-22 - workshop release. Ditch make_tester() + 0.3.4-pre 2024-09-22 - workshop pre-release. fix lots of wee bugs; add docs 0.3.3 2024-08-10 - consumers implementation