vc-utils 3.0__tar.gz → 3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vc-utils
3
- Version: 3.0
3
+ Version: 3.2
4
4
  Summary: Vulcan Coalition Python Utility Library
5
5
  Home-page: https://github.com/vulcan-coalition/vulcan-utils
6
6
  Author: Chatavut Viriyasuthee
@@ -3,7 +3,7 @@ from typing import Any, List, Optional
3
3
 
4
4
 
5
5
  class Achievement(BaseModel):
6
- title: str
7
- description: str
6
+ title: Optional[str] = None
7
+ description: Optional[str] = None
8
8
  metadata: Any = None
9
9
  files: Optional[List[str]] = None # paths to files to be uploaded
@@ -105,6 +105,18 @@ class Linkage_Application:
105
105
 
106
106
  # then invoke the post request with the token
107
107
  return await session.post(url, **kwargs)
108
+
109
+
110
+ async def linkage_patch(self, session, url, **kwargs):
111
+ if not self.token:
112
+ self.token = await application_get_token()
113
+
114
+ headers = kwargs.get("headers", {})
115
+ headers["Authorization"] = f"Bearer {self.token}"
116
+ kwargs["headers"] = headers
117
+
118
+ # then invoke the patch request with the token
119
+ return await session.patch(url, **kwargs)
108
120
 
109
121
 
110
122
  async def get_user_data(self, session, user_id, spec_id, download_url_expiration=3600):
@@ -129,6 +141,15 @@ class Linkage_Application:
129
141
  return await resp.json()
130
142
 
131
143
 
144
+ async def request_review_user_data(self, session, user_id, spec_id):
145
+ uri = f"{LINKAGE_M2M_HOST}/data/user/{user_id}/spec/{spec_id}"
146
+ resp = await self.linkage_patch(session, uri)
147
+ if resp.status != 200:
148
+ error_data = await resp.json()
149
+ raise Exception(error_data)
150
+ return await resp.json()
151
+
152
+
132
153
  async def update_achievement(self, session, user_id, achievement):
133
154
  """
134
155
  POST /achievements/user/{user_id}
@@ -141,8 +162,10 @@ class Linkage_Application:
141
162
  opened_files = []
142
163
  try:
143
164
  data = aiohttp.FormData()
144
- data.add_field("title", achievement.title)
145
- data.add_field("description", achievement.description)
165
+ if achievement.title is not None:
166
+ data.add_field("title", achievement.title)
167
+ if achievement.description is not None:
168
+ data.add_field("description", achievement.description)
146
169
  if achievement.metadata is not None:
147
170
  data.add_field("metadata", str(achievement.metadata))
148
171
  if achievement.files:
@@ -220,7 +243,7 @@ async def get_user_data(token, spec_id=None):
220
243
  }
221
244
  async with aiohttp.ClientSession() as session:
222
245
  if spec_id is not None:
223
- async with session.get(f"{LINKAGE_U2M_HOST}/data/{spec_id}", headers=headers) as resp:
246
+ async with session.get(f"{LINKAGE_U2M_HOST}/data/{spec_id}?auto_request=true", headers=headers) as resp:
224
247
  if resp.status != 200:
225
248
  error_data = await resp.json()
226
249
  raise Exception(error_data)
@@ -11,7 +11,7 @@ import shutil
11
11
 
12
12
  setup(
13
13
  name="vc-utils",
14
- version="3.0",
14
+ version="3.2",
15
15
  author="Chatavut Viriyasuthee",
16
16
  author_email="chatavut@lab.ai",
17
17
  description="Vulcan Coalition Python Utility Library",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vc-utils
3
- Version: 3.0
3
+ Version: 3.2
4
4
  Summary: Vulcan Coalition Python Utility Library
5
5
  Home-page: https://github.com/vulcan-coalition/vulcan-utils
6
6
  Author: Chatavut Viriyasuthee
File without changes
File without changes
File without changes
File without changes