fractal-server 2.5.0a0__py3-none-any.whl → 2.5.0a1__py3-none-any.whl

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 +1 @@
1
- __VERSION__ = "2.5.0a0"
1
+ __VERSION__ = "2.5.0a1"
@@ -32,7 +32,11 @@ async def _get_single_user_with_group_names(
32
32
  res = await db.execute(stm_groups)
33
33
  groups = res.scalars().unique().all()
34
34
  group_names = [group.name for group in groups]
35
- return UserRead(**user.model_dump(), group_names=group_names)
35
+ return UserRead(
36
+ **user.model_dump(),
37
+ group_names=group_names,
38
+ oauth_accounts=user.oauth_accounts,
39
+ )
36
40
 
37
41
 
38
42
  async def _get_single_user_with_group_ids(
@@ -53,7 +57,11 @@ async def _get_single_user_with_group_ids(
53
57
  res = await db.execute(stm_links)
54
58
  links = res.scalars().unique().all()
55
59
  group_ids = [link.group_id for link in links]
56
- return UserRead(**user.model_dump(), group_ids=group_ids)
60
+ return UserRead(
61
+ **user.model_dump(),
62
+ group_ids=group_ids,
63
+ oauth_accounts=user.oauth_accounts,
64
+ )
57
65
 
58
66
 
59
67
  async def _get_single_group_with_user_ids(
@@ -97,9 +105,7 @@ async def _user_or_404(user_id: int, db: AsyncSession) -> UserOAuth:
97
105
  user_id: ID of the user
98
106
  db: Async db session
99
107
  """
100
- stm = select(UserOAuth).where(UserOAuth.id == user_id)
101
- res = await db.execute(stm)
102
- user = res.scalars().unique().one_or_none()
108
+ user = await db.get(UserOAuth, user_id, populate_existing=True)
103
109
  if user is None:
104
110
  raise HTTPException(
105
111
  status_code=status.HTTP_404_NOT_FOUND, detail="User not found."
@@ -51,9 +51,13 @@ async def patch_current_user(
51
51
  # NOTE: here it would be relevant to catch an `InvalidPasswordException`
52
52
  # (from `fastapi_users.exceptions`), if we were to allow users change
53
53
  # their own password
54
+
54
55
  user = await user_manager.update(update, current_user, safe=True)
55
- patched_user = schemas.model_validate(UserOAuth, user)
56
+ validated_user = schemas.model_validate(UserOAuth, user)
56
57
 
58
+ patched_user = await db.get(
59
+ UserOAuth, validated_user.id, populate_existing=True
60
+ )
57
61
  patched_user_with_groups = await _get_single_user_with_group_names(
58
62
  patched_user, db
59
63
  )
@@ -43,10 +43,8 @@ async def get_user(
43
43
  ) -> UserRead:
44
44
  user = await _user_or_404(user_id, db)
45
45
  if group_ids:
46
- user_with_group_ids = await _get_single_user_with_group_ids(user, db)
47
- return user_with_group_ids
48
- else:
49
- return user
46
+ user = await _get_single_user_with_group_ids(user, db)
47
+ return user
50
48
 
51
49
 
52
50
  @router_users.patch("/users/{user_id}/", response_model=UserRead)
@@ -127,9 +125,7 @@ async def patch_user(
127
125
  status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
128
126
  detail=error_msg,
129
127
  )
130
-
131
128
  patched_user = user_to_patch
132
-
133
129
  elif edit_attributes:
134
130
  # Modify user attributes
135
131
  try:
@@ -142,7 +138,10 @@ async def patch_user(
142
138
  safe=False,
143
139
  request=None,
144
140
  )
145
- patched_user = schemas.model_validate(UserOAuth, user)
141
+ validated_user = schemas.model_validate(UserOAuth, user)
142
+ patched_user = await db.get(
143
+ UserOAuth, validated_user.id, populate_existing=True
144
+ )
146
145
  except exceptions.InvalidPasswordException as e:
147
146
  raise HTTPException(
148
147
  status_code=status.HTTP_400_BAD_REQUEST,
@@ -189,9 +188,11 @@ async def list_users(
189
188
  # https://github.com/fractal-analytics-platform/fractal-server/issues/1742
190
189
  for ind, user in enumerate(user_list):
191
190
  user_list[ind] = dict(
192
- user.model_dump(),
191
+ **user.model_dump(),
192
+ oauth_accounts=user.oauth_accounts,
193
193
  group_ids=[
194
194
  link.group_id for link in links if link.user_id == user.id
195
195
  ],
196
196
  )
197
+
197
198
  return user_list
@@ -20,6 +20,22 @@ __all__ = (
20
20
  )
21
21
 
22
22
 
23
+ class OAuthAccountRead(BaseModel):
24
+ """
25
+ Schema for storing essential `OAuthAccount` information within
26
+ `UserRead.oauth_accounts`.
27
+
28
+ Attributes:
29
+ id: ID of the row in fractal-owned `oauthaccount` table.
30
+ account_email: Email associated to OAuth account
31
+ oauth_name: Name of the OAuth provider (e.g. `github`)
32
+ """
33
+
34
+ id: int
35
+ account_email: str
36
+ oauth_name: str
37
+
38
+
23
39
  class UserRead(schemas.BaseUser[int]):
24
40
  """
25
41
  Schema for `User` read from database.
@@ -37,6 +53,7 @@ class UserRead(schemas.BaseUser[int]):
37
53
  slurm_accounts: list[str]
38
54
  group_names: Optional[list[str]] = None
39
55
  group_ids: Optional[list[int]] = None
56
+ oauth_accounts: list[OAuthAccountRead]
40
57
 
41
58
 
42
59
  class UserUpdate(schemas.BaseUserUpdate):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fractal-server
3
- Version: 2.5.0a0
3
+ Version: 2.5.0a1
4
4
  Summary: Server component of the Fractal analytics platform
5
5
  Home-page: https://github.com/fractal-analytics-platform/fractal-server
6
6
  License: BSD-3-Clause
@@ -1,4 +1,4 @@
1
- fractal_server/__init__.py,sha256=_rI4eT5b6qxaE6SGCTem_2zE6Wjz5WRJOKhvLkZ4pMs,24
1
+ fractal_server/__init__.py,sha256=1fM-hrX8GvZ3DcdEUtfHmLjQ5GtgW0uU1Sqd6Va9Mbo,24
2
2
  fractal_server/__main__.py,sha256=upYBkGYrkBnkS1rp4D_nb_1LS37QT4j-wxGX1ZMvR4A,5704
3
3
  fractal_server/alembic.ini,sha256=MWwi7GzjzawI9cCAK1LW7NxIBQDUqD12-ptJoq5JpP0,3153
4
4
  fractal_server/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -50,15 +50,15 @@ fractal_server/app/routes/api/v2/task_collection_custom.py,sha256=6MW-l7xTCTbWKD
50
50
  fractal_server/app/routes/api/v2/workflow.py,sha256=rMCcclz9aJAMSVLncUdSDGrgkKbn4KOCZTqZtqs2HDY,10428
51
51
  fractal_server/app/routes/api/v2/workflowtask.py,sha256=-3-c8DDnxGjMwWbX_h5V5OLaC_iCLXYzwWKBUaL-5wE,7060
52
52
  fractal_server/app/routes/auth/__init__.py,sha256=fao6CS0WiAjHDTvBzgBVV_bSXFpEAeDBF6Z6q7rRkPc,1658
53
- fractal_server/app/routes/auth/_aux_auth.py,sha256=Kpgiw5q1eiCYLFkfhTT7XJGBu1d08YM71CEHhNtfJ5g,3126
54
- fractal_server/app/routes/auth/current_user.py,sha256=LK0Z13NgaXYQ3FaQ3MNec0p2RRiKxKN31XIt2g9mcGk,2003
53
+ fractal_server/app/routes/auth/_aux_auth.py,sha256=G0-VwAq2UKlvKc5erCU8vhMQWA6gUgsRig9GmexEy74,3189
54
+ fractal_server/app/routes/auth/current_user.py,sha256=E6fDWw8xGxgE816S9Mriow1OMOaxw8DIKAFcrGpiaIU,2106
55
55
  fractal_server/app/routes/auth/group.py,sha256=az8kRJJU5rA0L8GCX5kvRNuQhrsoGWPuvQ26z7iFQ3E,5388
56
56
  fractal_server/app/routes/auth/group_names.py,sha256=zvYDfhxKlDmbSr-oLXYy6WUVkPPTvzH6ZJtuoNdGZbE,960
57
57
  fractal_server/app/routes/auth/login.py,sha256=tSu6OBLOieoBtMZB4JkBAdEgH2Y8KqPGSbwy7NIypIo,566
58
58
  fractal_server/app/routes/auth/oauth.py,sha256=AnFHbjqL2AgBX3eksI931xD6RTtmbciHBEuGf9YJLjU,1895
59
59
  fractal_server/app/routes/auth/register.py,sha256=DlHq79iOvGd_gt2v9uwtsqIKeO6i_GKaW59VIkllPqY,587
60
60
  fractal_server/app/routes/auth/router.py,sha256=zWoZWiO69U48QFQf5tLRYQDWu8PUCj7GacnaFeW1n_I,618
61
- fractal_server/app/routes/auth/users.py,sha256=5S_TD3elAeX0TBcvsME0i2_bSXEIGSuTrjRSOPPs3o0,6876
61
+ fractal_server/app/routes/auth/users.py,sha256=lMfcob_Bxz1j2EyddKeAoQPqMZTP40aOkiuk7Oeqo0E,6987
62
62
  fractal_server/app/routes/aux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  fractal_server/app/routes/aux/_job.py,sha256=q-RCiW17yXnZKAC_0La52RLvhqhxuvbgQJ2MlGXOj8A,702
64
64
  fractal_server/app/routes/aux/_runner.py,sha256=FdCVla5DxGAZ__aB7Z8dEJzD_RIeh5tftjrPyqkr8N8,895
@@ -124,7 +124,7 @@ fractal_server/app/runner/v2/task_interface.py,sha256=myS-kT0DsJ8xIJZBVEzgD8g54V
124
124
  fractal_server/app/runner/versions.py,sha256=dSaPRWqmFPHjg20kTCHmi_dmGNcCETflDtDLronNanU,852
125
125
  fractal_server/app/schemas/__init__.py,sha256=jiIf54owztXupv3PO6Ilh0qcrkh2RUzKq4bcEFqEfc4,40
126
126
  fractal_server/app/schemas/_validators.py,sha256=1dTOYr1IZykrxuQSV2-zuEMZbKe_nGwrfS7iUrsh-sE,3461
127
- fractal_server/app/schemas/user.py,sha256=jRMUd3v7kmnOdHhGSoljKbCk6xyaJuGHRXkaxAxI8RA,3437
127
+ fractal_server/app/schemas/user.py,sha256=PP0xU42hKeOGQLjOw5DnjaIISXrlbf2CHzCqAtv2_Bk,3889
128
128
  fractal_server/app/schemas/user_group.py,sha256=2f9XQ6kIar6NMY4UCN0yOnve6ZDHUVZaHv1dna1Vfjg,1446
129
129
  fractal_server/app/schemas/v1/__init__.py,sha256=CrBGgBhoemCvmZ70ZUchM-jfVAICnoa7AjZBAtL2UB0,1852
130
130
  fractal_server/app/schemas/v1/applyworkflow.py,sha256=uuIh7fHlHEL4yLqL-dePI6-nfCsqgBYATmht7w_KITw,4302
@@ -207,8 +207,8 @@ fractal_server/tasks/v2/utils.py,sha256=JOyCacb6MNvrwfLNTyLwcz8y79J29YuJeJ2MK5kq
207
207
  fractal_server/urls.py,sha256=5o_qq7PzKKbwq12NHSQZDmDitn5RAOeQ4xufu-2v9Zk,448
208
208
  fractal_server/utils.py,sha256=b7WwFdcFZ8unyT65mloFToYuEDXpQoHRcmRNqrhd_dQ,2115
209
209
  fractal_server/zip_tools.py,sha256=xYpzBshysD2nmxkD5WLYqMzPYUcCRM3kYy-7n9bJL-U,4426
210
- fractal_server-2.5.0a0.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
211
- fractal_server-2.5.0a0.dist-info/METADATA,sha256=K899Jp3wlYZMo1qI3MhmqiVJlcZQQxHQfa8reJVx9k0,4630
212
- fractal_server-2.5.0a0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
213
- fractal_server-2.5.0a0.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
214
- fractal_server-2.5.0a0.dist-info/RECORD,,
210
+ fractal_server-2.5.0a1.dist-info/LICENSE,sha256=QKAharUuhxL58kSoLizKJeZE3mTCBnX6ucmz8W0lxlk,1576
211
+ fractal_server-2.5.0a1.dist-info/METADATA,sha256=qMNa2O2LVr-uNvS2djtZyio4-mk3FOHbIY_7N6Mh31k,4630
212
+ fractal_server-2.5.0a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
213
+ fractal_server-2.5.0a1.dist-info/entry_points.txt,sha256=8tV2kynvFkjnhbtDnxAqImL6HMVKsopgGfew0DOp5UY,58
214
+ fractal_server-2.5.0a1.dist-info/RECORD,,