wbtools 3.2.0__tar.gz → 3.3.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.
Files changed (45) hide show
  1. {wbtools-3.2.0/wbtools.egg-info → wbtools-3.3.0}/PKG-INFO +2 -1
  2. {wbtools-3.2.0 → wbtools-3.3.0}/pyproject.toml +2 -1
  3. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/literature/paper.py +5 -2
  4. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/utils/alliance.py +1 -1
  5. wbtools-3.3.0/wbtools/utils/auth_utils.py +21 -0
  6. {wbtools-3.2.0 → wbtools-3.3.0/wbtools.egg-info}/PKG-INFO +2 -1
  7. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools.egg-info/SOURCES.txt +1 -1
  8. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools.egg-info/requires.txt +1 -0
  9. wbtools-3.2.0/wbtools/utils/okta_utils.py +0 -67
  10. {wbtools-3.2.0 → wbtools-3.3.0}/LICENSE +0 -0
  11. {wbtools-3.2.0 → wbtools-3.3.0}/README.md +0 -0
  12. {wbtools-3.2.0 → wbtools-3.3.0}/setup.cfg +0 -0
  13. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/__init__.py +0 -0
  14. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/__init__.py +0 -0
  15. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/abstract_manager.py +0 -0
  16. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/afp.py +0 -0
  17. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/antibody.py +0 -0
  18. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/dbmanager.py +0 -0
  19. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/expression.py +0 -0
  20. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/gene.py +0 -0
  21. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/generic.py +0 -0
  22. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/paper.py +0 -0
  23. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/db/person.py +0 -0
  24. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/__init__.py +0 -0
  25. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/email/__init__.py +0 -0
  26. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/email/generic.py +0 -0
  27. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/__init__.py +0 -0
  28. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/common.py +0 -0
  29. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/entity_extraction/__init__.py +0 -0
  30. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/entity_extraction/email_addresses.py +0 -0
  31. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/entity_extraction/ntt_extractor.py +0 -0
  32. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/entity_extraction/variations.py +0 -0
  33. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/literature_index/__init__.py +0 -0
  34. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/literature_index/abstract_index.py +0 -0
  35. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/literature_index/textpresso.py +0 -0
  36. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/text_preprocessing.py +0 -0
  37. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/nlp/text_similarity.py +0 -0
  38. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/scraping.py +0 -0
  39. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/lib/timeout.py +0 -0
  40. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/literature/__init__.py +0 -0
  41. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/literature/corpus.py +0 -0
  42. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/literature/person.py +0 -0
  43. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools/utils/__init__.py +0 -0
  44. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools.egg-info/dependency_links.txt +0 -0
  45. {wbtools-3.2.0 → wbtools-3.3.0}/wbtools.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wbtools
3
- Version: 3.2.0
3
+ Version: 3.3.0
4
4
  Summary: Interface to WormBase (www.wormbase.org) curation data, including literature management and NLP functions
5
5
  Author-email: Valerio Arnaboldi <valearna@caltech.edu>
6
6
  Project-URL: Homepage, https://github.com/WormBase/wbtools
@@ -24,6 +24,7 @@ Requires-Dist: requests~=2.31.0
24
24
  Requires-Dist: python-dateutil~=2.8.2
25
25
  Requires-Dist: python-dotenv~=1.0.0
26
26
  Requires-Dist: grobid-client
27
+ Requires-Dist: agr-cognito-py
27
28
 
28
29
  # WBtools
29
30
  > Interface to WormBase curation database and Text Mining functions
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "wbtools"
7
- version = "3.2.0"
7
+ version = "3.3.0"
8
8
  authors = [
9
9
  {name = "Valerio Arnaboldi", email = "valearna@caltech.edu"},
10
10
  ]
@@ -30,6 +30,7 @@ dependencies = [
30
30
  "python-dateutil~=2.8.2",
31
31
  "python-dotenv~=1.0.0",
32
32
  "grobid-client",
33
+ "agr-cognito-py",
33
34
  ]
34
35
 
35
36
  [project.urls]
@@ -26,7 +26,7 @@ from wbtools.lib.nlp.entity_extraction.email_addresses import get_email_addresse
26
26
  from wbtools.lib.nlp.text_preprocessing import preprocess, get_documents_from_text, PaperSections
27
27
  from wbtools.lib.timeout import timeout
28
28
  from wbtools.literature.person import WBAuthor
29
- from wbtools.utils.okta_utils import get_authentication_token, generate_headers
29
+ from wbtools.utils.auth_utils import get_authentication_token, generate_headers
30
30
 
31
31
  logger = logging.getLogger(__name__)
32
32
 
@@ -193,6 +193,7 @@ class WBPaper(object):
193
193
  blue_api_base_url = os.environ.get('API_SERVER', "literature-rest.alliancegenome.org")
194
194
  all_reffiles_for_pap_api = f'https://{blue_api_base_url}/reference/referencefile/show_all/{self.agr_curie}'
195
195
  request = urllib.request.Request(url=all_reffiles_for_pap_api)
196
+ request.add_header("Authorization", f"Bearer {get_authentication_token()}")
196
197
  request.add_header("Content-type", "application/json")
197
198
  request.add_header("Accept", "application/json")
198
199
  added_ref_files = 0
@@ -227,7 +228,9 @@ class WBPaper(object):
227
228
  raise Exception("PaperDBManager not set")
228
229
  # Get Alliance reference info from WBPaperID
229
230
  ref_info_from_xref_api = f"https://{ABC_API}/reference/by_cross_reference/WB:WBPaper{self.paper_id}"
230
- ref_info: dict = get_data_from_url(ref_info_from_xref_api)
231
+ token = get_authentication_token()
232
+ headers = generate_headers(token)
233
+ ref_info: dict = get_data_from_url(ref_info_from_xref_api, headers)
231
234
  if ref_info:
232
235
  self.abstract = ref_info["abstract"]
233
236
  self.title = ref_info["title"]
@@ -3,7 +3,7 @@ import logging
3
3
  import urllib.request
4
4
 
5
5
  from wbtools.lib.nlp.common import EntityType
6
- from wbtools.utils.okta_utils import get_authentication_token
6
+ from wbtools.utils.auth_utils import get_authentication_token
7
7
 
8
8
 
9
9
  logger = logging.getLogger(__name__)
@@ -0,0 +1,21 @@
1
+ """
2
+ Authentication utilities for AGR API access.
3
+
4
+ This module provides authentication token generation using AWS Cognito
5
+ via the agr_cognito_py library. The functions are re-exported for
6
+ backward compatibility with code that was using the old Okta-based
7
+ authentication.
8
+
9
+ Required environment variables for Cognito authentication:
10
+ - COGNITO_ADMIN_CLIENT_ID
11
+ - COGNITO_ADMIN_CLIENT_SECRET
12
+ - COGNITO_TOKEN_URL
13
+ - COGNITO_ADMIN_SCOPE
14
+ """
15
+
16
+ from agr_cognito_py import (
17
+ get_admin_token as get_authentication_token,
18
+ generate_headers
19
+ )
20
+
21
+ __all__ = ['get_authentication_token', 'generate_headers']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wbtools
3
- Version: 3.2.0
3
+ Version: 3.3.0
4
4
  Summary: Interface to WormBase (www.wormbase.org) curation data, including literature management and NLP functions
5
5
  Author-email: Valerio Arnaboldi <valearna@caltech.edu>
6
6
  Project-URL: Homepage, https://github.com/WormBase/wbtools
@@ -24,6 +24,7 @@ Requires-Dist: requests~=2.31.0
24
24
  Requires-Dist: python-dateutil~=2.8.2
25
25
  Requires-Dist: python-dotenv~=1.0.0
26
26
  Requires-Dist: grobid-client
27
+ Requires-Dist: agr-cognito-py
27
28
 
28
29
  # WBtools
29
30
  > Interface to WormBase curation database and Text Mining functions
@@ -39,4 +39,4 @@ wbtools/literature/paper.py
39
39
  wbtools/literature/person.py
40
40
  wbtools/utils/__init__.py
41
41
  wbtools/utils/alliance.py
42
- wbtools/utils/okta_utils.py
42
+ wbtools/utils/auth_utils.py
@@ -11,3 +11,4 @@ requests~=2.31.0
11
11
  python-dateutil~=2.8.2
12
12
  python-dotenv~=1.0.0
13
13
  grobid-client
14
+ agr-cognito-py
@@ -1,67 +0,0 @@
1
- import os
2
- from json import loads
3
- from os import environ, path
4
- import logging
5
- import logging.config
6
- from datetime import datetime
7
- from dateutil.relativedelta import relativedelta
8
- import requests
9
-
10
-
11
- def generate_headers(token):
12
- """
13
-
14
- :param token:
15
- :return:
16
- """
17
-
18
- authorization = 'Bearer ' + token
19
- headers = {
20
- 'Authorization': authorization,
21
- 'Content-Type': 'application/json',
22
- 'Accept': 'application/json'
23
- }
24
- return headers
25
-
26
-
27
- def update_okta_token(): # pragma: no cover
28
- """
29
-
30
- :return:
31
- """
32
-
33
- url = f"https://{os.environ.get('OKTA_DOMAIN')}/v1/token"
34
- headers = {
35
- 'Content-Type': 'application/x-www-form-urlencoded',
36
- 'Accept': 'application/json'
37
- }
38
- data_dict = dict()
39
- data_dict['grant_type'] = 'client_credentials'
40
- data_dict['client_id'] = environ.get('OKTA_CLIENT_ID')
41
- data_dict['client_secret'] = environ.get('OKTA_CLIENT_SECRET')
42
- data_dict['scope'] = 'admin'
43
- post_return = requests.post(url, headers=headers, data=data_dict)
44
- logging.warning(post_return.text)
45
- response_dict = loads(post_return.text)
46
- token = response_dict['access_token']
47
- okta_file = environ.get('TMP_PATH') + 'okta_token'
48
- os.makedirs(environ.get('TMP_PATH'), exist_ok=True)
49
- with open(okta_file, 'w') as okta_fh:
50
- okta_fh.write("%s" % token)
51
- return token
52
-
53
-
54
- def get_authentication_token(): # pragma: no cover
55
- okta_file = environ.get('TMP_PATH') + 'okta_token'
56
- token = ''
57
- if path.isfile(okta_file):
58
- one_day_ago = datetime.now() - relativedelta(days=1)
59
- file_time = datetime.fromtimestamp(path.getmtime(okta_file))
60
- if file_time > one_day_ago:
61
- with open(okta_file, 'r') as okta_fh:
62
- token = okta_fh.read().replace("\n", "")
63
- else:
64
- token = update_okta_token()
65
- else:
66
- token = update_okta_token()
67
- return token
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes