Skip to content

Commit 5fb0fc6

Browse files
authored
Merge pull request #36 from exnehilo7/master
Update version
2 parents 7cdaac3 + ecba15e commit 5fb0fc6

12 files changed

Lines changed: 1058 additions & 85 deletions

File tree

.github/workflows/action.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# 24-JAN-2025: Disable GitHub test action for now
2+
3+
# name: KBase SDK Tests
4+
5+
# on:
6+
# push:
7+
# branches:
8+
# - master
9+
# - main
10+
# pull_request:
11+
# branches:
12+
# - master
13+
# - main
14+
# - develop
15+
# schedule:
16+
# # Run quarterly on the 15th
17+
# - cron: '0 0 15 1,4,7,10 *'
18+
19+
# jobs:
20+
21+
# sdk_tests:
22+
# runs-on: ubuntu-latest
23+
# steps:
24+
25+
# - name: Check out GitHub repo
26+
# if: "!contains(github.event.head_commit.message, 'skip ci')"
27+
# uses: actions/checkout@v2
28+
29+
# - name: Check out Actions CI files
30+
# if: "!contains(github.event.head_commit.message, 'skip ci')"
31+
# uses: actions/checkout@v2
32+
# with:
33+
# repository: 'kbaseapps/kb_sdk_actions'
34+
# path: 'kb_sdk_actions'
35+
36+
37+
# - name: Set up test environment
38+
# if: "!contains(github.event.head_commit.message, 'skip ci')"
39+
# shell: bash
40+
# env:
41+
# KBASE_TEST_TOKEN: ${{ secrets.KBASE_TEST_TOKEN }}
42+
# run: |
43+
# # Verify kb_sdk_actions clone worked
44+
# test -f "$HOME/kb_sdk_actions/bin/kb-sdk" && echo "CI files cloned"
45+
# # Pull kb-sdk & create startup script
46+
# docker pull kbase/kb-sdk
47+
48+
# sh $GITHUB_WORKSPACE/kb_sdk_actions/bin/make_testdir && echo "Created test_local"
49+
# test -f "test_local/test.cfg" && echo "Confirmed config exists"
50+
51+
# - name: Configure authentication
52+
# if: "!contains(github.event.head_commit.message, 'skip ci')"
53+
# shell: bash
54+
# env:
55+
# KBASE_TEST_TOKEN: ${{ secrets.KBASE_TEST_TOKEN }}
56+
# run: |
57+
# # Add token to config
58+
# sed -ie "s/^test_token=.*$/&$KBASE_TEST_TOKEN/g" ./test_local/test.cfg
59+
60+
# - name: Run tests
61+
# if: "!contains(github.event.head_commit.message, 'skip ci')"
62+
# shell: bash
63+
# env:
64+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
65+
# run: |
66+
# sh $GITHUB_WORKSPACE/kb_sdk_actions/bin/kb-sdk test
67+
# bash <(curl -s https://codecov.io/bash)

Dockerfile

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM kbase/kbase:sdkbase2.latest
2-
MAINTAINER KBase Developer
2+
LABEL maintainer="KBase Developer"
33
# -----------------------------------------
44
# In this section, you can install any system dependencies required
55
# to run your App. For instance, you could place an apt-get update or
@@ -13,27 +13,21 @@ MAINTAINER KBase Developer
1313

1414
RUN pip install coverage
1515

16-
# update security libraries in the base image
17-
RUN pip install cffi --upgrade \
18-
&& pip install pyopenssl --upgrade \
19-
&& pip install ndg-httpsclient --upgrade \
20-
&& pip install pyasn1 --upgrade \
21-
&& pip install requests --upgrade \
22-
&& pip install 'requests[security]' --upgrade
23-
2416
# -----------------------------------------
2517

18+
# WORKDIR and Trimmomatic installation should be before COPY kb/module
19+
WORKDIR /kb/module
20+
21+
# Install Trimmomatic
22+
RUN curl -L https://github.com/usadellab/Trimmomatic/files/5854859/Trimmomatic-0.39.zip -o Trimmomatic-0.39.zip && \
23+
unzip Trimmomatic-0.39.zip
24+
2625
COPY ./ /kb/module
2726
RUN mkdir -p /kb/module/work
2827
RUN chmod -R a+rw /kb/module
2928

30-
WORKDIR /kb/module
31-
3229
RUN make all
3330

34-
# Install Trimmomatic
35-
RUN curl http://www.usadellab.org/cms/uploads/supplementary/Trimmomatic/Trimmomatic-0.36.zip -o Trimmomatic-0.36.zip && \
36-
unzip Trimmomatic-0.36.zip
3731

3832
ENTRYPOINT [ "./scripts/entrypoint.sh" ]
3933

RELEASE_NOTES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Version 1.2.15
2+
__Changes__
3+
- replaced AbstractHandle with DataFileUtil
4+
- updated github curl
5+
- upgrade to Trimmomatic version 0.39
6+
17
### Version 1.2.14
28
__Changes__
39
- improve docs

kbase.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ module-version:
1111
1.2.15
1212

1313
owners:
14-
[psdehal, dylan, wjriehl, umaganapathyswork, tgu2]
14+
[psdehal, dylan, wjriehl, umaganapathyswork, tgu2, dan_hopp]

lib/installed_clients/DataFileUtilClient.py

Lines changed: 546 additions & 0 deletions
Large diffs are not rendered by default.

lib/installed_clients/__init__.py

Whitespace-only changes.
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
'''
2+
Created on Aug 1, 2016
3+
4+
A very basic KBase auth client for the Python server.
5+
6+
@author: gaprice@lbl.gov
7+
'''
8+
import time as _time
9+
import requests as _requests
10+
import threading as _threading
11+
import hashlib
12+
13+
14+
class TokenCache(object):
15+
''' A basic cache for tokens. '''
16+
17+
_MAX_TIME_SEC = 5 * 60 # 5 min
18+
19+
_lock = _threading.RLock()
20+
21+
def __init__(self, maxsize=2000):
22+
self._cache = {}
23+
self._maxsize = maxsize
24+
self._halfmax = maxsize / 2 # int division to round down
25+
26+
def get_user(self, token):
27+
token = hashlib.sha256(token.encode('utf-8')).hexdigest()
28+
with self._lock:
29+
usertime = self._cache.get(token)
30+
if not usertime:
31+
return None
32+
33+
user, intime = usertime
34+
if _time.time() - intime > self._MAX_TIME_SEC:
35+
return None
36+
return user
37+
38+
def add_valid_token(self, token, user):
39+
if not token:
40+
raise ValueError('Must supply token')
41+
if not user:
42+
raise ValueError('Must supply user')
43+
token = hashlib.sha256(token.encode('utf-8')).hexdigest()
44+
with self._lock:
45+
self._cache[token] = [user, _time.time()]
46+
if len(self._cache) > self._maxsize:
47+
sorted_items = sorted(
48+
list(self._cache.items()),
49+
key=(lambda v: v[1][1])
50+
)
51+
for i, (t, _) in enumerate(sorted_items):
52+
if i <= self._halfmax:
53+
del self._cache[t]
54+
else:
55+
break
56+
57+
58+
class KBaseAuth(object):
59+
'''
60+
A very basic KBase auth client for the Python server.
61+
'''
62+
63+
_LOGIN_URL = 'https://kbase.us/services/auth/api/legacy/KBase/Sessions/Login'
64+
65+
def __init__(self, auth_url=None):
66+
'''
67+
Constructor
68+
'''
69+
self._authurl = auth_url
70+
if not self._authurl:
71+
self._authurl = self._LOGIN_URL
72+
self._cache = TokenCache()
73+
74+
def get_user(self, token):
75+
if not token:
76+
raise ValueError('Must supply token')
77+
user = self._cache.get_user(token)
78+
if user:
79+
return user
80+
81+
d = {'token': token, 'fields': 'user_id'}
82+
ret = _requests.post(self._authurl, data=d)
83+
if not ret.ok:
84+
try:
85+
err = ret.json()
86+
except Exception as e:
87+
ret.raise_for_status()
88+
raise ValueError('Error connecting to auth service: {} {}\n{}'
89+
.format(ret.status_code, ret.reason,
90+
err['error']['message']))
91+
92+
user = ret.json()['user_id']
93+
self._cache.add_valid_token(token, user)
94+
return user

0 commit comments

Comments
 (0)