Skip to content

Commit

Permalink
Fix build, add coverage, ignore google download tests
Browse files Browse the repository at this point in the history
Google download doesn't seem to work currently.

Also
* Updated service auth client. There's something strange here - the
authclient didn't get updated on a compile, so I did it manually.
* Deleted the unused baseclient in lib
* Just fetched the one jar from `jars` rather than cloning the whole
thing
* Got rid of `six`
  • Loading branch information
MrCreosote committed Mar 11, 2024
1 parent e921d1f commit bbcfc70
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 293 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/kb_sdk_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ jobs:
shell: bash
run: |
sh $GITHUB_WORKSPACE/kb_sdk_actions/bin/kb-sdk test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
test_local
sdk.cfg
/bin/
/.classpath
/.project
/.pydevproject
*.py.bak-*
20 changes: 7 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
FROM kbase/sdkbase2:python
FROM kbase/sdkpython:3.8.10
MAINTAINER KBase Developer
# -----------------------------------------

# Insert apt-get instructions here to install
# any required dependencies for your module.

RUN mkdir -p /opt/lib

RUN apt-get update \
&& apt-get install -y g++ \
&& apt-get install libz-dev\
&& apt-get install nano \
&& apt-get install tree
&& apt-get install -y g++ libz-dev wget nano tree

# Debug tools = all below six
RUN pip install six \
&& pip install ipython==5.3.0 \
&& pip install pyftpdlib==1.5.6
RUN wget -O /opt/lib/FastaValidator-1.0.jar https://github.com/kbase/jars/raw/master/lib/jars/FastaValidator/FastaValidator-1.0.jar

RUN pip install ipython==5.3.0 pyftpdlib==1.5.6

RUN cd /opt \
&& git clone https://github.com/kbase/jars \
&& mkdir lib \
&& cp jars/lib/jars/FastaValidator/FastaValidator-1.0.jar lib

RUN cd /opt \
&& git clone https://github.com/statgen/libStatGen.git \
Expand Down
2 changes: 1 addition & 1 deletion ReadsUtils.html

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/ReadsUtils/ReadsUtilsImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ReadsUtils:
# state. A method could easily clobber the state set by another while
# the latter method is running.
######################################### noqa
VERSION = "0.3.13"
GIT_URL = "https://github.com/Tianhao-Gu/ReadsUtils.git"
GIT_COMMIT_HASH = "6882a74364922dbdacea2714f225fa57fd4b3b2f"
VERSION = "1.0.0"
GIT_URL = "https://github.com/kbaseapps/ReadsUtils.git"
GIT_COMMIT_HASH = "e921d1fa303c14bd0298353cdf73087fdeb6f884"

#BEGIN_CLASS_HEADER

Expand Down Expand Up @@ -97,7 +97,7 @@ def _proc_upload_reads_params(self, params):
dfu = DataFileUtil(self.callback_url)
if wsname:
self.log('Translating workspace name to id')
if not isinstance(wsname, six.string_types):
if not isinstance(wsname, str):
raise ValueError('wsname must be a string')
wsid = dfu.ws_name_to_id(wsname)
self.log('translation done')
Expand Down
17 changes: 10 additions & 7 deletions lib/ReadsUtils/authclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, maxsize=2000):
self._halfmax = maxsize / 2 # int division to round down

def get_user(self, token):
token = hashlib.sha256(token).hexdigest()
token = hashlib.sha256(token.encode('utf-8')).hexdigest()
with self._lock:
usertime = self._cache.get(token)
if not usertime:
Expand All @@ -40,12 +40,15 @@ def add_valid_token(self, token, user):
raise ValueError('Must supply token')
if not user:
raise ValueError('Must supply user')
token = hashlib.sha256(token).hexdigest()
token = hashlib.sha256(token.encode('utf-8')).hexdigest()
with self._lock:
self._cache[token] = [user, _time.time()]
if len(self._cache) > self._maxsize:
for i, (t, _) in enumerate(sorted(self._cache.items(),
key=lambda (_, v): v[1])):
sorted_items = sorted(
list(self._cache.items()),
key=(lambda v: v[1][1])
)
for i, (t, _) in enumerate(sorted_items):
if i <= self._halfmax:
del self._cache[t]
else:
Expand All @@ -57,7 +60,7 @@ class KBaseAuth(object):
A very basic KBase auth client for the Python server.
'''

_LOGIN_URL = 'https://kbase.us/services/authorization/Sessions/Login'
_LOGIN_URL = 'https://kbase.us/services/auth/api/legacy/KBase/Sessions/Login'

def __init__(self, auth_url=None):
'''
Expand All @@ -80,11 +83,11 @@ def get_user(self, token):
if not ret.ok:
try:
err = ret.json()
except:
except Exception as e:
ret.raise_for_status()
raise ValueError('Error connecting to auth service: {} {}\n{}'
.format(ret.status_code, ret.reason,
err['error_msg']))
err['error']['message']))

user = ret.json()['user_id']
self._cache.add_valid_token(token, user)
Expand Down
268 changes: 0 additions & 268 deletions lib/ReadsUtils/baseclient.py

This file was deleted.

Loading

0 comments on commit bbcfc70

Please sign in to comment.