Skip to content

Commit

Permalink
0.3.4 release for workshop - ditch make_tester()
Browse files Browse the repository at this point in the history
  • Loading branch information
bkuczenski committed Sep 23, 2024
1 parent 88854cc commit 63e870a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
26 changes: 8 additions & 18 deletions antelope_core/catalog/lc_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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'):
Expand Down
3 changes: 3 additions & 0 deletions antelope_core/providers/xdb_client/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 63e870a

Please sign in to comment.