truefoundry 0.5.8rc1__py3-none-any.whl → 0.5.8rc3__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.

Potentially problematic release.


This version of truefoundry might be problematic. Click here for more details.

@@ -1,5 +1,4 @@
1
1
  import time
2
- from enum import Enum
3
2
  from typing import Optional
4
3
 
5
4
  import jwt
@@ -8,18 +7,12 @@ from typing_extensions import NotRequired, TypedDict
8
7
  from truefoundry.pydantic_v1 import BaseModel, Field, NonEmptyStr, validator
9
8
 
10
9
 
11
- class UserType(Enum):
12
- user = "user"
13
- serviceaccount = "serviceaccount"
14
-
15
-
16
10
  class UserInfo(BaseModel):
17
11
  class Config:
18
12
  allow_population_by_field_name = True
19
13
  allow_mutation = False
20
14
 
21
15
  user_id: NonEmptyStr
22
- user_type: UserType = UserType.user
23
16
  email: Optional[str] = None
24
17
  tenant_name: NonEmptyStr = Field(alias="tenantName")
25
18
 
@@ -27,9 +20,16 @@ class UserInfo(BaseModel):
27
20
  class _DecodedToken(TypedDict):
28
21
  tenantName: str
29
22
  exp: int
30
- username: str
23
+ username: NotRequired[str]
31
24
  email: NotRequired[str]
32
- userType: UserType
25
+
26
+
27
+ def _user_slug(decoded_token: _DecodedToken) -> str:
28
+ return (
29
+ decoded_token.get("username")
30
+ or decoded_token.get("email")
31
+ or "--user-slug-missing--"
32
+ )
33
33
 
34
34
 
35
35
  class Token(BaseModel):
@@ -55,19 +55,21 @@ class Token(BaseModel):
55
55
 
56
56
  @property
57
57
  def tenant_name(self) -> str:
58
+ assert self.decoded_value is not None
58
59
  return self.decoded_value["tenantName"]
59
60
 
60
61
  def is_going_to_be_expired(self, buffer_in_seconds: int = 120) -> bool:
62
+ assert self.decoded_value is not None
61
63
  exp = int(self.decoded_value["exp"])
62
64
  return (exp - time.time()) < buffer_in_seconds
63
65
 
64
66
  def to_user_info(self) -> UserInfo:
67
+ assert self.decoded_value is not None
65
68
  return UserInfo(
66
- user_id=self.decoded_value["username"],
69
+ user_id=_user_slug(self.decoded_value),
67
70
  email=self.decoded_value["email"]
68
71
  if "email" in self.decoded_value
69
72
  else None,
70
- user_type=UserType(self.decoded_value.get("userType", UserType.user.value)),
71
73
  tenant_name=self.tenant_name,
72
74
  )
73
75
 
@@ -50,10 +50,9 @@ class Session:
50
50
 
51
51
  ACTIVE_SESSION = new_session
52
52
  logger.info(
53
- "Logged in to %r as %r (%s)",
53
+ "Logged in to %r as %r",
54
54
  new_session.tfy_host,
55
55
  new_session.user_info.user_id,
56
- new_session.user_info.email or new_session.user_info.user_type.value,
57
56
  )
58
57
 
59
58
  return ACTIVE_SESSION
@@ -57,10 +57,9 @@ def login(
57
57
  return login(api_key=api_key, host=host, relogin=True)
58
58
 
59
59
  user_info = cred_file_content.to_token().to_user_info()
60
- user_name_display_info = user_info.email or user_info.user_type.value
61
60
  output_hook.print_line(
62
61
  relogin_error_message(
63
- f"Already logged in to {cred_file_content.host!r} as {user_info.user_id!r} ({user_name_display_info})",
62
+ f"Already logged in to {cred_file_content.host!r} as {user_info.user_id!r}",
64
63
  host=host,
65
64
  )
66
65
  )
@@ -81,10 +80,9 @@ def login(
81
80
  cred_file.write(cred_file_content)
82
81
 
83
82
  user_info = token.to_user_info()
84
- user_name_display_info = user_info.email or user_info.user_type.value
85
83
  output_hook.print_line(
86
84
  f"Successfully logged in to {cred_file_content.host!r} as "
87
- f"{user_info.user_id!r} ({user_name_display_info})"
85
+ f"{user_info.user_id!r}"
88
86
  )
89
87
  return True
90
88
 
truefoundry/ml/session.py CHANGED
@@ -75,10 +75,9 @@ class MLFoundrySession(Session):
75
75
 
76
76
  ACTIVE_SESSION = new_session
77
77
  logger.info(
78
- "Logged in to %r as %r (%s)",
78
+ "Logged in to %r as %r",
79
79
  new_session.tfy_host,
80
80
  new_session.user_info.user_id,
81
- new_session.user_info.email or new_session.user_info.user_type.value,
82
81
  )
83
82
 
84
83
  return ACTIVE_SESSION
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: truefoundry
3
- Version: 0.5.8rc1
3
+ Version: 0.5.8rc3
4
4
  Summary: TrueFoundry CLI
5
5
  Author: Abhishek Choudhary
6
6
  Author-email: abhishek@truefoundry.com
@@ -35,11 +35,11 @@ truefoundry/common/auth_service_client.py,sha256=N3YxKlx63r6cPZqbgb2lqBOPI69ShB7
35
35
  truefoundry/common/constants.py,sha256=WQjylPv7xTVYURv4zicJUHYL73Gv3c3i6Iw4oy9Lhg4,2744
36
36
  truefoundry/common/credential_file_manager.py,sha256=1yEk1Zm2xS4G0VDFwKSZ4w0VUrcPWQ1nJnoBaz9xyKA,4251
37
37
  truefoundry/common/credential_provider.py,sha256=_OhJ2XFlDaVsrUO-FyywxctcGGqDdC2pgcvwEKqQD0Q,4071
38
- truefoundry/common/entities.py,sha256=12olLKzRT092Jnze5busK68cwH8wwyL6ch77ohKOFPU,3723
38
+ truefoundry/common/entities.py,sha256=Gx52dIwUARwGLE2hCSe9PJWfXh-ARCmdWwX6KtCxJng,3805
39
39
  truefoundry/common/exceptions.py,sha256=jkU0N7hV_P-EhXeud4I5vuB9glXXZSWPf8LcH04mSbw,459
40
40
  truefoundry/common/request_utils.py,sha256=e9qrAQ1MutU7JALDKcucmNd0KQEVBqgW3yx0w1zeHIU,5700
41
41
  truefoundry/common/servicefoundry_client.py,sha256=2fYhdVPSvLXz5C5tosOq86JD8WM3IRUIy1VO9deDxZI,3340
42
- truefoundry/common/session.py,sha256=BiTJ2WEzLkTvzpqy67xX3fXgiKH_ltzzmQdFG7xUtwI,2904
42
+ truefoundry/common/session.py,sha256=xeBAPUNEJv2XVFQCRUGeBDTePh5zrKNSok8vmSxBjPw,2813
43
43
  truefoundry/common/storage_provider_utils.py,sha256=yURhMw8k0FLFvaviRHDiifhvc6GnuQwGMC9Qd2uM440,10934
44
44
  truefoundry/common/types.py,sha256=BMJFCsR1lPJAw66IQBSvLyV4I6o_x5oj78gVsUa9si8,188
45
45
  truefoundry/common/utils.py,sha256=E1kKw_hqlVMgwyPkER2SvVLIoQ-B_4TQCuM5IJXvgig,6046
@@ -93,7 +93,7 @@ truefoundry/deploy/lib/logs_utils.py,sha256=SQxRv3jDDmgHdOUMhlMaAPGYskybnBUMpst7
93
93
  truefoundry/deploy/lib/messages.py,sha256=nhp0bCYf_XpUM68hTq5lBY-__vtEyV2uP7NgnJXJ_Vg,925
94
94
  truefoundry/deploy/lib/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
95
95
  truefoundry/deploy/lib/model/entity.py,sha256=3YRdyvMYI1aUXUu2tB5b5lZWwpxKdAhjpT79gzTCZGo,8373
96
- truefoundry/deploy/lib/session.py,sha256=FBSq3bxf3my_613NzgtPoeeaAYLGZEoF0n7XccTFNf4,5141
96
+ truefoundry/deploy/lib/session.py,sha256=GIt2eTU6jWQwMkvseDJccSWdUVyEr3WLY5AKHf8Uy18,4931
97
97
  truefoundry/deploy/lib/util.py,sha256=J7r8San2wKo48A7-BlH2-OKTlBO67zlPjLEhMsL8os0,1059
98
98
  truefoundry/deploy/lib/win32.py,sha256=1RcvPTdlOAJ48rt8rCbE2Ufha2ztRqBAE9dueNXArrY,5009
99
99
  truefoundry/deploy/python_deploy_codegen.py,sha256=qJHH1BJQII9e6PhkcRFYiE_3De7_VMMm8nM4AX5Eq1o,6513
@@ -349,7 +349,7 @@ truefoundry/ml/mlfoundry_api.py,sha256=PUBGDcjrZsJKQYy1PjT8NYGYxrTvhhHzQ-0jLSl7-
349
349
  truefoundry/ml/mlfoundry_run.py,sha256=M-0FkZYDxwv5EZUDtVqiV8JxC_3BWR80N7Kp4Yj7bPY,44291
350
350
  truefoundry/ml/model_framework.py,sha256=JGmzdG7o5P6CJr5EYTUOmuly53FfhpoNVqKrhfijAVg,18972
351
351
  truefoundry/ml/run_utils.py,sha256=0W208wSLUrbdfk2pjNcZlkUi9bNxG2JORqoe-5rVqHI,2423
352
- truefoundry/ml/session.py,sha256=eQo1zG5nd0-8Ok68uEBCQDPAWYeJkpzqHak-DQX1ENU,4553
352
+ truefoundry/ml/session.py,sha256=IRXVoAAJTHik3md-pE4IpTPSGJvs5qdAyWBf0O9_TJo,4462
353
353
  truefoundry/ml/validation_utils.py,sha256=J5atNhcJLvKj64ralSV9Y5Fv1Rt4SE237ICdP9-7sP4,12149
354
354
  truefoundry/pydantic_v1.py,sha256=jSuhGtz0Mbk1qYu8jJ1AcnIDK4oxUsdhALc4spqstmM,345
355
355
  truefoundry/version.py,sha256=bqiT4Q-VWrTC6P4qfK43mez-Ppf-smWfrl6DcwV7mrw,137
@@ -363,7 +363,7 @@ truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=xcT0wQmQl
363
363
  truefoundry/workflow/remote_filesystem/tfy_signed_url_fs.py,sha256=nSGPZu0Gyd_jz0KsEE-7w_BmnTD8CVF1S8cUJoxaCbc,13305
364
364
  truefoundry/workflow/task.py,sha256=34m55mALXx6ko9o5HkK6FDtMajdvJzBhOsHwDM2RcBA,1779
365
365
  truefoundry/workflow/workflow.py,sha256=WaTqUjhwfAXDWu4E5ehuwAxrCbDJkoAf1oWmR2E9Qy0,4575
366
- truefoundry-0.5.8rc1.dist-info/METADATA,sha256=w78rupDdfwn-65YZwSnGEBgIqFfc3B-kWigUjyUWY6I,2887
367
- truefoundry-0.5.8rc1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
368
- truefoundry-0.5.8rc1.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
369
- truefoundry-0.5.8rc1.dist-info/RECORD,,
366
+ truefoundry-0.5.8rc3.dist-info/METADATA,sha256=jWpi5FBYbnjWyjtakUC0pIyFydEUPuqSGitw0-VpCns,2887
367
+ truefoundry-0.5.8rc3.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
368
+ truefoundry-0.5.8rc3.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
369
+ truefoundry-0.5.8rc3.dist-info/RECORD,,