willisapi-client 1.4__tar.gz → 1.5__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 (40) hide show
  1. {willisapi_client-1.4 → willisapi_client-1.5}/PKG-INFO +1 -1
  2. {willisapi_client-1.4 → willisapi_client-1.5}/tests/test_auth.py +4 -100
  3. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/__init__.py +1 -2
  4. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/__version__.py +1 -1
  5. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/api.py +1 -1
  6. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/auth/__init__.py +1 -5
  7. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/auth/auth_utils.py +0 -40
  8. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/auth/user_group_manager.py +1 -1
  9. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/download/download_utils.py +11 -36
  10. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client.egg-info/PKG-INFO +1 -1
  11. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client.egg-info/SOURCES.txt +0 -1
  12. willisapi_client-1.4/willisapi_client/services/auth/user_manager.py +0 -59
  13. {willisapi_client-1.4 → willisapi_client-1.5}/LICENSE +0 -0
  14. {willisapi_client-1.4 → willisapi_client-1.5}/MANIFEST.in +0 -0
  15. {willisapi_client-1.4 → willisapi_client-1.5}/README.md +0 -0
  16. {willisapi_client-1.4 → willisapi_client-1.5}/RELEASE.md +0 -0
  17. {willisapi_client-1.4 → willisapi_client-1.5}/requirements.txt +0 -0
  18. {willisapi_client-1.4 → willisapi_client-1.5}/setup.cfg +0 -0
  19. {willisapi_client-1.4 → willisapi_client-1.5}/setup.py +0 -0
  20. {willisapi_client-1.4 → willisapi_client-1.5}/tests/test_csv_validation.py +0 -0
  21. {willisapi_client-1.4 → willisapi_client-1.5}/tests/test_download.py +0 -0
  22. {willisapi_client-1.4 → willisapi_client-1.5}/tests/test_upload.py +0 -0
  23. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/logging_setup.py +0 -0
  24. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/__init__.py +0 -0
  25. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/auth/login_manager.py +0 -0
  26. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/download/__init__.py +0 -0
  27. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/download/download_handler.py +0 -0
  28. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/exceptions.py +0 -0
  29. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/upload/__init__.py +0 -0
  30. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/upload/csv_validation.py +0 -0
  31. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/upload/language_choices.py +0 -0
  32. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/upload/multipart_upload_handler.py +0 -0
  33. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/upload/upload_utils.py +0 -0
  34. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/services/upload/utils.py +0 -0
  35. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/timer.py +0 -0
  36. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client/willisapi_client.py +0 -0
  37. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client.egg-info/dependency_links.txt +0 -0
  38. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client.egg-info/not-zip-safe +0 -0
  39. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client.egg-info/requires.txt +0 -0
  40. {willisapi_client-1.4 → willisapi_client-1.5}/willisapi_client.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: willisapi_client
3
- Version: 1.4
3
+ Version: 1.5
4
4
  Summary: A Python client for willisapi
5
5
  Home-page: https://github.com/bklynhlth/willsiapi_client
6
6
  Author: bklynhlth
@@ -1,5 +1,4 @@
1
1
  from willisapi_client.services.auth.login_manager import login
2
- from willisapi_client.services.auth.user_manager import create_user
3
2
  from willisapi_client.services.auth.user_group_manager import create_account
4
3
  from unittest.mock import patch
5
4
  from datetime import timedelta, datetime
@@ -107,7 +106,7 @@ class TestLoginFunction:
107
106
  self.client_name,
108
107
  )
109
108
  print(result)
110
- assert result == None
109
+ assert result == "Python error"
111
110
 
112
111
  @patch("willisapi_client.services.auth.user_group_manager.AuthUtils.create_account")
113
112
  def test_create_account_failed_401_status(self, mocked_create_account):
@@ -121,7 +120,7 @@ class TestLoginFunction:
121
120
  self.client_name,
122
121
  )
123
122
  print(result)
124
- assert result == None
123
+ assert result == "Not an Admin User"
125
124
 
126
125
  @patch("willisapi_client.services.auth.user_group_manager.AuthUtils.create_account")
127
126
  def test_create_account_failed_409_status(self, mocked_create_account):
@@ -135,7 +134,7 @@ class TestLoginFunction:
135
134
  self.client_name,
136
135
  )
137
136
  print(result)
138
- assert result == None
137
+ assert result == "User already exists or already in some group"
139
138
 
140
139
  @patch("willisapi_client.services.auth.user_group_manager.AuthUtils.create_account")
141
140
  def test_create_account_failed_404_status(self, mocked_create_account):
@@ -149,99 +148,4 @@ class TestLoginFunction:
149
148
  self.client_name,
150
149
  )
151
150
  print(result)
152
- assert result == None
153
-
154
-
155
- class TestSignupFunction:
156
- def setup_method(self):
157
- self.username = "dummy"
158
- self.password = "password"
159
- self.admin_key = "admin_key"
160
- self.non_admin_key = "non_admin_key"
161
- self.client_email = "client@email.com"
162
- self.client_name = "client"
163
- self.first_name = "First"
164
- self.last_name = "Last"
165
-
166
- @patch("willisapi_client.services.auth.login_manager.AuthUtils.signup")
167
- def test_signup_failed(self, mocked_signup):
168
- mocked_signup.return_value = {
169
- "status_code": 200,
170
- "message": "Not an admin user",
171
- }
172
- message = create_user(
173
- self.non_admin_key,
174
- self.client_email,
175
- self.client_name,
176
- self.first_name,
177
- self.last_name,
178
- )
179
- assert message == "Not an admin user"
180
-
181
- @patch("willisapi_client.services.auth.login_manager.AuthUtils.signup")
182
- def test_signup_success(self, mocked_signup):
183
- mocked_signup.return_value = {"status_code": 200, "message": "User created"}
184
- message = create_user(
185
- self.admin_key,
186
- self.client_email,
187
- self.client_name,
188
- self.first_name,
189
- self.last_name,
190
- )
191
- assert message == "User created"
192
-
193
- @patch("willisapi_client.services.auth.login_manager.AuthUtils.signup")
194
- def test_signup_failed_400_status(self, mocked_signup):
195
- mocked_signup.return_value = {
196
- "status_code": 400,
197
- }
198
- message = create_user(
199
- self.admin_key,
200
- self.client_email,
201
- self.client_name,
202
- self.first_name,
203
- self.last_name,
204
- )
205
- assert message == None
206
-
207
- @patch("willisapi_client.services.auth.login_manager.AuthUtils.signup")
208
- def test_signup_failed_500_status(self, mocked_signup):
209
- mocked_signup.return_value = {
210
- "status_code": 500,
211
- }
212
- message = create_user(
213
- self.admin_key,
214
- self.client_email,
215
- self.client_name,
216
- self.first_name,
217
- self.last_name,
218
- )
219
- assert message == None
220
-
221
- @patch("willisapi_client.services.auth.login_manager.AuthUtils.signup")
222
- def test_signup_failed_401_status(self, mocked_signup):
223
- mocked_signup.return_value = {
224
- "status_code": 401,
225
- }
226
- message = create_user(
227
- self.admin_key,
228
- self.client_email,
229
- self.client_name,
230
- self.first_name,
231
- self.last_name,
232
- )
233
- assert message == None
234
-
235
- @patch("willisapi_client.services.auth.login_manager.AuthUtils.signup")
236
- def test_signup_failed_403_status(self, mocked_signup):
237
- mocked_signup.return_value = {
238
- "status_code": 403,
239
- }
240
- message = create_user(
241
- self.admin_key,
242
- self.client_email,
243
- self.client_name,
244
- self.first_name,
245
- self.last_name,
246
- )
247
- assert message == None
151
+ assert result == "User not found"
@@ -3,10 +3,9 @@
3
3
  # import the required packages
4
4
  from willisapi_client.services.api import (
5
5
  login,
6
- create_user,
7
6
  upload,
8
7
  download,
9
8
  create_account,
10
9
  )
11
10
 
12
- __all__ = ["login", "create_user", "upload", "download", "create_account"]
11
+ __all__ = ["login", "upload", "download", "create_account"]
@@ -1,7 +1,7 @@
1
1
  """Version details for willisapi_client
2
2
  """
3
3
  __client__ = "willisapi_client"
4
- __latestVersion__ = "1.4"
4
+ __latestVersion__ = "1.5"
5
5
  __url__ = "https://github.com/bklynhlth/willsiapi_client"
6
6
  __short_description__ = "A Python client for willisapi"
7
7
  __content_type__ = "text/markdown"
@@ -1,6 +1,6 @@
1
1
  # website: https://www.brooklyn.health
2
2
 
3
3
  # import the required packages
4
- from willisapi_client.services.auth import login, create_user, create_account
4
+ from willisapi_client.services.auth import login, create_account
5
5
  from willisapi_client.services.upload import upload
6
6
  from willisapi_client.services.download import download
@@ -2,10 +2,6 @@
2
2
  from willisapi_client.services.auth.login_manager import (
3
3
  login,
4
4
  )
5
- from willisapi_client.services.auth.user_manager import (
6
- create_user,
7
- )
8
-
9
5
  from willisapi_client.services.auth.user_group_manager import create_account
10
6
 
11
- __all__ = ["login", "create_user", "create_account"]
7
+ __all__ = ["login", "create_account"]
@@ -50,46 +50,6 @@ class AuthUtils:
50
50
  else:
51
51
  return res_json
52
52
 
53
- @staticmethod
54
- def signup(url, data, headers, try_number):
55
- """
56
- ------------------------------------------------------------------------------------------------------
57
- Class: AuthUtils
58
-
59
- Function: signup
60
-
61
- Description: This is an internal signup function which makes a POST API call to the brooklyn.health API server.
62
-
63
- Parameters:
64
- ----------
65
- url: The URL of the API endpoint.
66
- data: The data to be sent in the request body.
67
- headers: The headers to be sent in the request.
68
- try_number: The number of times the function has been tried.
69
-
70
- Returns:
71
- ----------
72
- json: The JSON response from the API server.
73
-
74
- Raises:
75
- ----------
76
- UnableToOnboardClientError: If the function fails to signup after 3 tries.
77
- ------------------------------------------------------------------------------------------------------
78
- """
79
- try:
80
- response = requests.post(url, json=data, headers=headers)
81
- res_json = response.json()
82
- except (
83
- requests.exceptions.ConnectionError,
84
- json.decoder.JSONDecodeError,
85
- ) as ex:
86
- if try_number == 3:
87
- raise UnableToOnboardClientError
88
- time.sleep(random.random() * 2)
89
- return AuthUtils.signup(url, data, headers, try_number=try_number + 1)
90
- else:
91
- return res_json
92
-
93
53
  @staticmethod
94
54
  def create_account(url, data, headers, try_number):
95
55
  """
@@ -61,7 +61,7 @@ def create_account(
61
61
  logger.info(
62
62
  f'{datetime.now().strftime("%H:%M:%S")}: User already present in the group'
63
63
  )
64
- return response["message"]
64
+ return response["message"]
65
65
  else:
66
66
  logger.error(f"Login Failed")
67
67
  return None
@@ -5,12 +5,9 @@ import random
5
5
  import pandas as pd
6
6
  from typing import Tuple
7
7
 
8
- emotional_expressivity_summary = "emotional_expressivity_summary"
9
- facial_expressivity_summary = "facial_expressivity_summary"
10
8
  vocal_acoustic_summary = "vocal_acoustics_summary"
11
9
  speech_characteristics_summary = "speech_characteristics_summary"
12
10
  rater_qa_summary = "rater_qa_summary"
13
- eye_blinks_summary = "eye_blink_rate_summary"
14
11
 
15
12
 
16
13
  class DownloadUtils:
@@ -164,22 +161,17 @@ class DownloadUtils:
164
161
  measures_dict = response["items"]["project"]["participant"][pt]["results"][rec][
165
162
  "measures"
166
163
  ]
167
- if workflow_tag in measures_dict:
168
- if measures_dict[workflow_tag]:
169
- if workflow_tag in [
170
- emotional_expressivity_summary,
171
- facial_expressivity_summary,
172
- ]:
173
- return pd.read_json(
174
- json.dumps(measures_dict[workflow_tag][0])
175
- ).head(1)
176
- if workflow_tag in [
177
- vocal_acoustic_summary,
178
- speech_characteristics_summary,
179
- rater_qa_summary,
180
- eye_blinks_summary,
181
- ]:
182
- return pd.read_json(json.dumps(measures_dict[workflow_tag][0]))
164
+ if (
165
+ workflow_tag in measures_dict
166
+ and measures_dict[workflow_tag]
167
+ and workflow_tag
168
+ in [
169
+ vocal_acoustic_summary,
170
+ speech_characteristics_summary,
171
+ rater_qa_summary,
172
+ ]
173
+ ):
174
+ return pd.read_json(json.dumps(measures_dict[workflow_tag][0]))
183
175
  return pd.DataFrame()
184
176
 
185
177
  def generate_response_df(response) -> Tuple[pd.DataFrame, str]:
@@ -221,16 +213,6 @@ class DownloadUtils:
221
213
  columns=DownloadUtils._get_defined_columns(),
222
214
  )
223
215
 
224
- emotional_expressivity_summary_df = (
225
- DownloadUtils._get_summary_df_from_json(
226
- response, pt, rec, emotional_expressivity_summary
227
- )
228
- )
229
- facial_expressivity_summary_df = (
230
- DownloadUtils._get_summary_df_from_json(
231
- response, pt, rec, facial_expressivity_summary
232
- )
233
- )
234
216
  vocal_acoustics_summary_df = (
235
217
  DownloadUtils._get_summary_df_from_json(
236
218
  response, pt, rec, vocal_acoustic_summary
@@ -241,21 +223,14 @@ class DownloadUtils:
241
223
  response, pt, rec, speech_characteristics_summary
242
224
  )
243
225
  )
244
-
245
- eye_blinks_summary_df = DownloadUtils._get_summary_df_from_json(
246
- response, pt, rec, eye_blinks_summary
247
- )
248
226
  rater_qa_summary_df = DownloadUtils._get_summary_df_from_json(
249
227
  response, pt, rec, rater_qa_summary
250
228
  )
251
229
  df = pd.concat(
252
230
  [
253
231
  main_df,
254
- emotional_expressivity_summary_df,
255
- facial_expressivity_summary_df,
256
232
  vocal_acoustics_summary_df,
257
233
  speech_characteristics_summary_df,
258
- eye_blinks_summary_df,
259
234
  rater_qa_summary_df,
260
235
  ],
261
236
  axis=1,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: willisapi-client
3
- Version: 1.4
3
+ Version: 1.5
4
4
  Summary: A Python client for willisapi
5
5
  Home-page: https://github.com/bklynhlth/willsiapi_client
6
6
  Author: bklynhlth
@@ -27,7 +27,6 @@ willisapi_client/services/auth/__init__.py
27
27
  willisapi_client/services/auth/auth_utils.py
28
28
  willisapi_client/services/auth/login_manager.py
29
29
  willisapi_client/services/auth/user_group_manager.py
30
- willisapi_client/services/auth/user_manager.py
31
30
  willisapi_client/services/download/__init__.py
32
31
  willisapi_client/services/download/download_handler.py
33
32
  willisapi_client/services/download/download_utils.py
@@ -1,59 +0,0 @@
1
- # website: https://www.brooklyn.health
2
- from http import HTTPStatus
3
-
4
- from willisapi_client.willisapi_client import WillisapiClient
5
- from willisapi_client.services.auth.auth_utils import AuthUtils
6
- from willisapi_client.logging_setup import logger as logger
7
-
8
-
9
- def create_user(
10
- key: str,
11
- client_email: str,
12
- client_name: str,
13
- first_name: str,
14
- last_name: str,
15
- **kwargs,
16
- ) -> str:
17
- """
18
- ---------------------------------------------------------------------------------------------------
19
- Function: create_user
20
-
21
- Description: This is the signup function to access willisAPI signup API
22
-
23
- Parameters:
24
- ----------
25
- key: Admin access token
26
- client_email: string representation of client email id
27
- client_name: stringbrepresentation of expected client name without empty spaces
28
- first_name: User's first name
29
- last_name: User's last_name
30
-
31
- Returns:
32
- ----------
33
- status : Onboard succes/fail message (str/None)
34
- ---------------------------------------------------------------------------------------------------
35
- """
36
-
37
- wc = WillisapiClient(env=kwargs.get("env"))
38
- url = wc.get_signup_url()
39
- headers = wc.get_headers()
40
- headers["Authorization"] = key
41
- data = dict(
42
- client_email=client_email,
43
- client_name=client_name,
44
- first_name=first_name,
45
- last_name=last_name,
46
- )
47
- response = AuthUtils.signup(url, data, headers, try_number=1)
48
- if (
49
- response
50
- and "status_code" in response
51
- and response["status_code"] == HTTPStatus.OK
52
- ):
53
- logger.info(
54
- f"Signup Successful for client: {client_name}, client_email: {client_email}"
55
- )
56
- return response["message"]
57
- else:
58
- logger.error(f"Signup Failed")
59
- return None
File without changes
File without changes
File without changes
File without changes