bacdive 1.0.0__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bacdive-1.0.0 → bacdive-2.0.0}/PKG-INFO +18 -13
- {bacdive-1.0.0 → bacdive-2.0.0}/README.md +4 -9
- {bacdive-1.0.0 → bacdive-2.0.0}/bacdive/client.py +7 -47
- {bacdive-1.0.0 → bacdive-2.0.0}/bacdive.egg-info/PKG-INFO +18 -13
- {bacdive-1.0.0 → bacdive-2.0.0}/bacdive.egg-info/requires.txt +0 -1
- {bacdive-1.0.0 → bacdive-2.0.0}/setup.py +1 -2
- {bacdive-1.0.0 → bacdive-2.0.0}/LICENSE +0 -0
- {bacdive-1.0.0 → bacdive-2.0.0}/bacdive/__init__.py +0 -0
- {bacdive-1.0.0 → bacdive-2.0.0}/bacdive.egg-info/SOURCES.txt +0 -0
- {bacdive-1.0.0 → bacdive-2.0.0}/bacdive.egg-info/dependency_links.txt +0 -0
- {bacdive-1.0.0 → bacdive-2.0.0}/bacdive.egg-info/top_level.txt +0 -0
- {bacdive-1.0.0 → bacdive-2.0.0}/pyproject.toml +0 -0
- {bacdive-1.0.0 → bacdive-2.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: bacdive
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: BacDive-API - Programmatic Access to the BacDive Database
|
|
5
5
|
Home-page: https://bacdive.dsmz.de/
|
|
6
6
|
Author: Julia Koblitz
|
|
@@ -13,23 +13,28 @@ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
|
13
13
|
Requires-Python: >=3.6
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: python-keycloak
|
|
17
16
|
Requires-Dist: requests>=2.25.1
|
|
18
17
|
Requires-Dist: urllib3>=1.26.5
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: keywords
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# BacDive API v2
|
|
31
|
+
|
|
32
|
+
Using the BacDive API does not require registration anymore, but the usage of BacDive data is only permitted when in compliance with the BacDive terms of use. See [About BacDive](https://bacdive.dsmz.de/about) for details.
|
|
28
33
|
|
|
29
34
|
```python
|
|
30
35
|
import bacdive
|
|
31
36
|
|
|
32
|
-
client = bacdive.BacdiveClient(
|
|
37
|
+
client = bacdive.BacdiveClient()
|
|
33
38
|
|
|
34
39
|
# [optional] You may define the search type as one of the following:
|
|
35
40
|
# 'exact' (default), 'contains', 'startswith', 'endswith'
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
# BacDive API
|
|
2
|
-
|
|
3
|
-
Using the BacDive API requires registration. Registration is free but the usage of BacDive data is only permitted when in compliance with the BacDive terms of use. See [About BacDive](https://bacdive.dsmz.de/about) for details.
|
|
4
|
-
|
|
5
|
-
Please register [here](https://api.bacdive.dsmz.de/login).
|
|
6
|
-
|
|
7
|
-
The Python package can be initialized using your login credentials:
|
|
1
|
+
# BacDive API v2
|
|
8
2
|
|
|
3
|
+
Using the BacDive API does not require registration anymore, but the usage of BacDive data is only permitted when in compliance with the BacDive terms of use. See [About BacDive](https://bacdive.dsmz.de/about) for details.
|
|
9
4
|
|
|
10
5
|
```python
|
|
11
6
|
import bacdive
|
|
12
7
|
|
|
13
|
-
client = bacdive.BacdiveClient(
|
|
8
|
+
client = bacdive.BacdiveClient()
|
|
14
9
|
|
|
15
10
|
# [optional] You may define the search type as one of the following:
|
|
16
11
|
# 'exact' (default), 'contains', 'startswith', 'endswith'
|
|
@@ -119,4 +114,4 @@ client.excludePredictions()
|
|
|
119
114
|
|
|
120
115
|
Thanks to [phenolophthaleinum](https://github.com/phenolophthaleinum) for improving the error handling and Joaquim Sardá for improving the BacDive-API and adding new search possibilities.
|
|
121
116
|
|
|
122
|
-
Examples for search type definitions and array requests are included in the examples above.
|
|
117
|
+
Examples for search type definitions and array requests are included in the examples above.
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
'''
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
terms of use. See https://bacdive.dsmz.de/about for details.
|
|
5
|
-
|
|
6
|
-
Please register at https://api.bacdive.dsmz.de/login.
|
|
2
|
+
This package is for using the BacDive API V2 (2026-02).
|
|
3
|
+
Registration is not required anymore.
|
|
7
4
|
'''
|
|
8
5
|
|
|
9
|
-
from keycloak.exceptions import KeycloakAuthenticationError, KeycloakPostError, KeycloakConnectionError
|
|
10
|
-
from keycloak import KeycloakOpenID
|
|
11
6
|
from requests.adapters import HTTPAdapter
|
|
12
7
|
from urllib3.util.retry import Retry
|
|
13
8
|
import requests
|
|
@@ -29,7 +24,7 @@ class ReportRetry(Retry):
|
|
|
29
24
|
|
|
30
25
|
|
|
31
26
|
class BacdiveClient():
|
|
32
|
-
def __init__(self, user, password, public=True, max_retries=10, retry_delay=50, request_timeout=300):
|
|
27
|
+
def __init__(self, user=None, password=None, public=True, max_retries=10, retry_delay=50, request_timeout=300):
|
|
33
28
|
''' Initialize client and authenticate on the server '''
|
|
34
29
|
self.result = {}
|
|
35
30
|
self.public = public
|
|
@@ -46,32 +41,6 @@ class BacdiveClient():
|
|
|
46
41
|
else:
|
|
47
42
|
server_url = "https://sso.dmz.dsmz.de/auth/"
|
|
48
43
|
|
|
49
|
-
self.keycloak_openid = KeycloakOpenID(
|
|
50
|
-
server_url=server_url,
|
|
51
|
-
client_id=client_id,
|
|
52
|
-
realm_name="dsmz")
|
|
53
|
-
|
|
54
|
-
for _ in range(self.max_retries):
|
|
55
|
-
try:
|
|
56
|
-
# Get tokens
|
|
57
|
-
token = self.keycloak_openid.token(user, password)
|
|
58
|
-
self.access_token = token['access_token']
|
|
59
|
-
self.refresh_token = token['refresh_token']
|
|
60
|
-
print("-- Authentication successful --")
|
|
61
|
-
except KeycloakAuthenticationError as e:
|
|
62
|
-
print(f"ERROR - Keycloak Authentication failed: {e}\n Retrying in {self.retry_delay} seconds")
|
|
63
|
-
time.sleep(self.retry_delay)
|
|
64
|
-
except KeycloakConnectionError as e:
|
|
65
|
-
print(f"ERROR - Keycloak Connection failed: {e}\n Retrying in {self.retry_delay} seconds")
|
|
66
|
-
time.sleep(self.retry_delay)
|
|
67
|
-
except KeycloakPostError as e:
|
|
68
|
-
print(f"ERROR - Keycloak Connection failed: {e}\n Retrying in {self.retry_delay} seconds")
|
|
69
|
-
time.sleep(self.retry_delay)
|
|
70
|
-
else:
|
|
71
|
-
break # break loop if successful
|
|
72
|
-
else:
|
|
73
|
-
print(f"ERROR - Keycloak authentication failed after {self.max_retries} retries.")
|
|
74
|
-
|
|
75
44
|
def includePredictions(self):
|
|
76
45
|
self.predictions = True
|
|
77
46
|
|
|
@@ -92,9 +61,9 @@ class BacdiveClient():
|
|
|
92
61
|
def do_api_call(self, url):
|
|
93
62
|
''' Initialize API call on given URL and returns result as json '''
|
|
94
63
|
if self.public:
|
|
95
|
-
baseurl = "https://api.bacdive.dsmz.de/"
|
|
64
|
+
baseurl = "https://api.bacdive.dsmz.de/v2/"
|
|
96
65
|
else:
|
|
97
|
-
baseurl = "http://api.bacdive-dev.dsmz.local/"
|
|
66
|
+
baseurl = "http://api.bacdive-dev.dsmz.local/v2/"
|
|
98
67
|
|
|
99
68
|
if not url.startswith("http"):
|
|
100
69
|
# if base is missing add default:
|
|
@@ -107,23 +76,14 @@ class BacdiveClient():
|
|
|
107
76
|
elif (resp.status_code == 401):
|
|
108
77
|
msg = json.loads(resp.content)
|
|
109
78
|
|
|
110
|
-
if msg['message'] == "Expired token":
|
|
111
|
-
# Access token might have expired (15 minutes life time).
|
|
112
|
-
# Get new tokens using refresh token and try again.
|
|
113
|
-
token = self.keycloak_openid.refresh_token(self.refresh_token)
|
|
114
|
-
self.access_token = token['access_token']
|
|
115
|
-
self.refresh_token = token['refresh_token']
|
|
116
|
-
return self.do_api_call(url)
|
|
117
|
-
|
|
118
79
|
return msg
|
|
119
80
|
else:
|
|
120
81
|
return json.loads(resp.content)
|
|
121
82
|
|
|
122
83
|
def do_request(self, url):
|
|
123
|
-
''' Perform request
|
|
84
|
+
''' Perform request'''
|
|
124
85
|
headers = {
|
|
125
86
|
"Accept": "application/json",
|
|
126
|
-
"Authorization": "Bearer {token}".format(token=self.access_token)
|
|
127
87
|
}
|
|
128
88
|
|
|
129
89
|
if self.predictions:
|
|
@@ -163,7 +123,7 @@ class BacdiveClient():
|
|
|
163
123
|
def retrieve(self, filter=None):
|
|
164
124
|
''' Yields all the received entries and does next call if result is incomplete '''
|
|
165
125
|
ids = ";".join([str(i) for i in self.result['results']])
|
|
166
|
-
entries = self.do_api_call('fetch/'+ids)['results']
|
|
126
|
+
entries = self.do_api_call('fetch/'+ids)['results'] if ids else []
|
|
167
127
|
for el in entries:
|
|
168
128
|
if isinstance(el, dict):
|
|
169
129
|
entry = el
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: bacdive
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: BacDive-API - Programmatic Access to the BacDive Database
|
|
5
5
|
Home-page: https://bacdive.dsmz.de/
|
|
6
6
|
Author: Julia Koblitz
|
|
@@ -13,23 +13,28 @@ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
|
13
13
|
Requires-Python: >=3.6
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: python-keycloak
|
|
17
16
|
Requires-Dist: requests>=2.25.1
|
|
18
17
|
Requires-Dist: urllib3>=1.26.5
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: keywords
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
Dynamic: requires-dist
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
Dynamic: summary
|
|
29
|
+
|
|
30
|
+
# BacDive API v2
|
|
31
|
+
|
|
32
|
+
Using the BacDive API does not require registration anymore, but the usage of BacDive data is only permitted when in compliance with the BacDive terms of use. See [About BacDive](https://bacdive.dsmz.de/about) for details.
|
|
28
33
|
|
|
29
34
|
```python
|
|
30
35
|
import bacdive
|
|
31
36
|
|
|
32
|
-
client = bacdive.BacdiveClient(
|
|
37
|
+
client = bacdive.BacdiveClient()
|
|
33
38
|
|
|
34
39
|
# [optional] You may define the search type as one of the following:
|
|
35
40
|
# 'exact' (default), 'contains', 'startswith', 'endswith'
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="bacdive",
|
|
8
|
-
version="
|
|
8
|
+
version="2.0.0",
|
|
9
9
|
description="BacDive-API - Programmatic Access to the BacDive Database",
|
|
10
10
|
long_description=long_description,
|
|
11
11
|
long_description_content_type="text/markdown",
|
|
@@ -22,7 +22,6 @@ setuptools.setup(
|
|
|
22
22
|
],
|
|
23
23
|
keywords="microbiology bacteria strains phenotypes",
|
|
24
24
|
install_requires=[
|
|
25
|
-
"python-keycloak",
|
|
26
25
|
"requests>=2.25.1",
|
|
27
26
|
"urllib3>=1.26.5"
|
|
28
27
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|