truefoundry 0.4.0rc2__py3-none-any.whl → 0.4.0rc3__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.

Files changed (81) hide show
  1. truefoundry/__init__.py +2 -0
  2. truefoundry/autodeploy/agents/developer.py +1 -1
  3. truefoundry/autodeploy/agents/project_identifier.py +2 -2
  4. truefoundry/autodeploy/agents/tester.py +1 -1
  5. truefoundry/autodeploy/cli.py +1 -1
  6. truefoundry/autodeploy/tools/list_files.py +1 -1
  7. truefoundry/{deploy/lib/auth → common}/auth_service_client.py +50 -40
  8. truefoundry/common/constants.py +12 -0
  9. truefoundry/{deploy/lib/auth → common}/credential_file_manager.py +7 -7
  10. truefoundry/{deploy/lib/auth → common}/credential_provider.py +9 -12
  11. truefoundry/{ml/services → common}/entities.py +57 -41
  12. truefoundry/common/exceptions.py +12 -0
  13. truefoundry/common/request_utils.py +36 -8
  14. truefoundry/common/servicefoundry_client.py +91 -0
  15. truefoundry/common/utils.py +56 -0
  16. truefoundry/deploy/auto_gen/models.py +4 -6
  17. truefoundry/deploy/cli/cli.py +2 -0
  18. truefoundry/deploy/cli/commands/apply_command.py +1 -1
  19. truefoundry/deploy/cli/commands/build_command.py +1 -1
  20. truefoundry/deploy/cli/commands/deploy_command.py +1 -1
  21. truefoundry/deploy/cli/commands/login_command.py +2 -2
  22. truefoundry/deploy/cli/commands/patch_application_command.py +1 -1
  23. truefoundry/deploy/cli/commands/patch_command.py +1 -1
  24. truefoundry/deploy/cli/commands/terminate_comand.py +1 -1
  25. truefoundry/deploy/cli/util.py +1 -1
  26. truefoundry/deploy/function_service/remote/remote.py +1 -1
  27. truefoundry/deploy/lib/auth/servicefoundry_session.py +2 -2
  28. truefoundry/deploy/lib/clients/servicefoundry_client.py +120 -150
  29. truefoundry/deploy/lib/const.py +1 -35
  30. truefoundry/deploy/lib/exceptions.py +0 -11
  31. truefoundry/deploy/lib/model/entity.py +1 -112
  32. truefoundry/deploy/lib/session.py +13 -26
  33. truefoundry/deploy/lib/util.py +0 -37
  34. truefoundry/deploy/v2/lib/deploy.py +3 -3
  35. truefoundry/ml/__init__.py +0 -2
  36. truefoundry/ml/artifact/truefoundry_artifact_repo.py +63 -22
  37. truefoundry/ml/autogen/client/__init__.py +0 -3
  38. truefoundry/ml/autogen/client/api/experiments_api.py +0 -165
  39. truefoundry/ml/autogen/client/models/__init__.py +0 -3
  40. truefoundry/ml/autogen/client/models/artifact_dto.py +6 -6
  41. truefoundry/ml/autogen/client/models/artifact_version_dto.py +8 -8
  42. truefoundry/ml/autogen/client/models/create_artifact_response_dto.py +2 -3
  43. truefoundry/ml/autogen/client/models/create_artifact_version_response_dto.py +2 -3
  44. truefoundry/ml/autogen/client/models/create_python_deployment_config_request_dto.py +2 -2
  45. truefoundry/ml/autogen/client/models/create_python_deployment_config_response_dto.py +2 -3
  46. truefoundry/ml/autogen/client/models/create_run_request_dto.py +5 -5
  47. truefoundry/ml/autogen/client/models/create_run_response_dto.py +2 -3
  48. truefoundry/ml/autogen/client/models/dataset_dto.py +10 -10
  49. truefoundry/ml/autogen/client/models/experiment_dto.py +18 -18
  50. truefoundry/ml/autogen/client/models/get_latest_run_log_response_dto.py +2 -3
  51. truefoundry/ml/autogen/client/models/get_tenant_id_response_dto.py +4 -5
  52. truefoundry/ml/autogen/client/models/model_dto.py +6 -6
  53. truefoundry/ml/autogen/client/models/model_version_dto.py +15 -8
  54. truefoundry/ml/autogen/client/models/run_info_dto.py +10 -10
  55. truefoundry/ml/autogen/client/models/update_run_response_dto.py +2 -3
  56. truefoundry/ml/autogen/client_README.md +0 -2
  57. truefoundry/ml/clients/entities.py +8 -0
  58. truefoundry/ml/{services/servicefoundry_service.py → clients/servicefoundry_client.py} +20 -10
  59. truefoundry/ml/{services → clients}/utils.py +2 -2
  60. truefoundry/ml/env_vars.py +1 -5
  61. truefoundry/ml/internal_namespace.py +8 -8
  62. truefoundry/ml/log_types/artifacts/artifact.py +7 -3
  63. truefoundry/ml/log_types/artifacts/dataset.py +1 -1
  64. truefoundry/ml/log_types/artifacts/model.py +7 -8
  65. truefoundry/ml/log_types/image/image.py +7 -8
  66. truefoundry/ml/log_types/image/image_normalizer.py +7 -6
  67. truefoundry/ml/mlfoundry_api.py +5 -17
  68. truefoundry/ml/mlfoundry_run.py +0 -5
  69. truefoundry/ml/run_utils.py +1 -10
  70. truefoundry/ml/session.py +14 -117
  71. truefoundry/pydantic_v1.py +1 -1
  72. truefoundry/workflow/__init__.py +16 -1
  73. {truefoundry-0.4.0rc2.dist-info → truefoundry-0.4.0rc3.dist-info}/METADATA +1 -1
  74. {truefoundry-0.4.0rc2.dist-info → truefoundry-0.4.0rc3.dist-info}/RECORD +77 -76
  75. truefoundry/deploy/lib/clients/utils.py +0 -41
  76. truefoundry/ml/autogen/client/models/backfill_default_storage_integration_id_request_dto.py +0 -67
  77. truefoundry/ml/login.py +0 -241
  78. truefoundry/ml/services/auth_service.py +0 -109
  79. /truefoundry/ml/{services → clients}/__init__.py +0 -0
  80. {truefoundry-0.4.0rc2.dist-info → truefoundry-0.4.0rc3.dist-info}/WHEEL +0 -0
  81. {truefoundry-0.4.0rc2.dist-info → truefoundry-0.4.0rc3.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,56 @@
1
+ import os
2
+ import time
3
+ from functools import lru_cache, wraps
4
+ from time import monotonic_ns
5
+ from typing import Callable, Generator, Optional, TypeVar
6
+ from urllib.parse import urljoin, urlsplit
7
+
8
+ from truefoundry.common.constants import (
9
+ API_SERVER_RELATIVE_PATH,
10
+ SERVICEFOUNDRY_SERVER_URL_ENV_KEY,
11
+ TFY_HOST_ENV_KEY,
12
+ )
13
+
14
+ T = TypeVar("T")
15
+
16
+
17
+ def timed_lru_cache(
18
+ seconds: int = 300, maxsize: Optional[int] = None
19
+ ) -> Callable[[Callable[..., T]], Callable[..., T]]:
20
+ def wrapper_cache(func: Callable[..., T]) -> Callable[..., T]:
21
+ func = lru_cache(maxsize=maxsize)(func)
22
+ func.delta = seconds * 10**9
23
+ func.expiration = monotonic_ns() + func.delta
24
+
25
+ @wraps(func)
26
+ def wrapped_func(*args, **kwargs):
27
+ if monotonic_ns() >= func.expiration:
28
+ func.cache_clear()
29
+ func.expiration = monotonic_ns() + func.delta
30
+ return func(*args, **kwargs)
31
+
32
+ return wrapped_func
33
+
34
+ return wrapper_cache
35
+
36
+
37
+ def poll_for_function(
38
+ func: Callable[..., T], poll_after_secs: int = 5, *args, **kwargs
39
+ ) -> Generator[T, None, None]:
40
+ while True:
41
+ yield func(*args, **kwargs)
42
+ time.sleep(poll_after_secs)
43
+
44
+
45
+ def resolve_base_url(host: Optional[str] = None) -> str:
46
+ if not host and not os.getenv(TFY_HOST_ENV_KEY):
47
+ raise ValueError(
48
+ f"Either `host` should be provided by --host <value>, or `{TFY_HOST_ENV_KEY}` env must be set"
49
+ )
50
+ return host or os.getenv(TFY_HOST_ENV_KEY)
51
+
52
+
53
+ def append_servicefoundry_path_to_base_url(base_url: str):
54
+ if urlsplit(base_url).netloc.startswith("localhost"):
55
+ return os.getenv(SERVICEFOUNDRY_SERVER_URL_ENV_KEY)
56
+ return urljoin(base_url, API_SERVER_RELATIVE_PATH)
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: application.json
3
- # timestamp: 2024-09-19T11:05:06+00:00
3
+ # timestamp: 2024-09-29T10:28:22+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -310,9 +310,7 @@ class GcpTPU(BaseModel):
310
310
 
311
311
 
312
312
  class GitHelmRepo(BaseModel):
313
- type: constr(regex=r"^git-helm-repo$") = Field(
314
- ..., description="+value=git-helm-repo"
315
- )
313
+ type: Literal["git-helm-repo"] = Field(..., description="+value=git-helm-repo")
316
314
  repo_url: constr(
317
315
  regex=r"^(((https?|wss):\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))$"
318
316
  ) = Field(
@@ -357,7 +355,7 @@ class GitSource(BaseModel):
357
355
 
358
356
 
359
357
  class HelmRepo(BaseModel):
360
- type: constr(regex=r"^helm-repo$") = Field(..., description="+value=helm-repo")
358
+ type: Literal["helm-repo"] = Field(..., description="+value=helm-repo")
361
359
  repo_url: constr(
362
360
  regex=r"^(((https?|wss):\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))$"
363
361
  ) = Field(
@@ -647,7 +645,7 @@ class OCIRepo(BaseModel):
647
645
  +label=OCIRepo
648
646
  """
649
647
 
650
- type: constr(regex=r"^oci-repo$") = Field(..., description="+value=oci-repo")
648
+ type: Literal["oci-repo"] = Field(..., description="+value=oci-repo")
651
649
  oci_chart_url: constr(
652
650
  regex=r"^(((oci):\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))$"
653
651
  ) = Field(..., description="+label=OCI chart URL\n+message=Need to be a valid URL.")
@@ -13,6 +13,7 @@ from truefoundry.deploy.cli.commands import (
13
13
  get_logout_command,
14
14
  get_patch_application_command,
15
15
  get_patch_command,
16
+ get_terminate_command,
16
17
  get_trigger_command,
17
18
  )
18
19
  from truefoundry.deploy.cli.config import CliConfig
@@ -38,6 +39,7 @@ def create_truefoundry_cli() -> click.MultiCommand:
38
39
  cli.add_command(get_patch_application_command())
39
40
  cli.add_command(get_delete_command())
40
41
  cli.add_command(get_trigger_command())
42
+ cli.add_command(get_terminate_command())
41
43
 
42
44
  if not (sys.platform.startswith("win32") or sys.platform.startswith("cygwin")):
43
45
  cli.add_command(get_patch_command())
@@ -17,7 +17,7 @@ from truefoundry.deploy.lib.model.entity import ApplyResult
17
17
  name="apply",
18
18
  cls=GROUP_CLS,
19
19
  invoke_without_command=True,
20
- help="Create resources by appling manifest locally from Truefoundry spec",
20
+ help="Create resources by applying manifest locally from TrueFoundry spec",
21
21
  context_settings={"ignore_unknown_options": True, "allow_interspersed_args": True},
22
22
  )
23
23
  @click.option(
@@ -13,7 +13,7 @@ from truefoundry.version import __version__
13
13
  name="build",
14
14
  cls=GROUP_CLS,
15
15
  invoke_without_command=True,
16
- help="Build docker image locally from Truefoundry spec",
16
+ help="Build docker image locally from TrueFoundry spec",
17
17
  context_settings={"ignore_unknown_options": True, "allow_interspersed_args": True},
18
18
  )
19
19
  @click.option(
@@ -29,7 +29,7 @@ def _get_default_spec_file():
29
29
  name="deploy",
30
30
  cls=GROUP_CLS,
31
31
  invoke_without_command=True,
32
- help="Deploy application to Truefoundry",
32
+ help="Deploy application to TrueFoundry",
33
33
  )
34
34
  @click.option(
35
35
  "-f",
@@ -1,18 +1,18 @@
1
1
  import rich_click as click
2
2
 
3
+ from truefoundry.common.constants import TFY_HOST_ENV_KEY
3
4
  from truefoundry.deploy.cli.const import COMMAND_CLS
4
5
  from truefoundry.deploy.cli.util import (
5
6
  _prompt_if_no_value_and_supported,
6
7
  handle_exception_wrapper,
7
8
  )
8
9
  from truefoundry.deploy.io.rich_output_callback import RichOutputCallBack
9
- from truefoundry.deploy.lib.const import HOST_ENV_NAME
10
10
  from truefoundry.deploy.lib.session import login
11
11
 
12
12
 
13
13
  @click.command(name="login", cls=COMMAND_CLS)
14
14
  @click.option("--relogin", type=click.BOOL, is_flag=True, default=False)
15
- @click.option("--host", type=click.STRING, required=True, envvar=HOST_ENV_NAME)
15
+ @click.option("--host", type=click.STRING, required=True, envvar=TFY_HOST_ENV_KEY)
16
16
  @click.option(
17
17
  "--api-key",
18
18
  "--api_key",
@@ -12,7 +12,7 @@ from truefoundry.deploy.lib.dao import application as application_lib
12
12
  name="patch-application",
13
13
  cls=GROUP_CLS,
14
14
  invoke_without_command=True,
15
- help="Deploy application with patches to Truefoundry",
15
+ help="Deploy application with patches to TrueFoundry",
16
16
  )
17
17
  @click.option(
18
18
  "-f",
@@ -12,7 +12,7 @@ from truefoundry.deploy.io.rich_output_callback import RichOutputCallBack
12
12
  name="patch",
13
13
  cls=GROUP_CLS,
14
14
  invoke_without_command=True,
15
- help="Patch parts of servicefoundry.yaml file",
15
+ help="Patch parts of truefoundry.yaml file",
16
16
  )
17
17
  @click.option(
18
18
  "-f",
@@ -9,7 +9,7 @@ from truefoundry.deploy.lib.dao import application as application_lib
9
9
  @click.group(name="terminate", cls=GROUP_CLS)
10
10
  def terminate_command():
11
11
  """
12
- Terminate the job
12
+ Terminate Job Runs
13
13
  """
14
14
  pass
15
15
 
@@ -10,9 +10,9 @@ from rich.padding import Padding
10
10
  from rich.panel import Panel
11
11
  from rich.table import Table
12
12
 
13
+ from truefoundry.common.exceptions import BadRequestException
13
14
  from truefoundry.deploy.cli.console import console
14
15
  from truefoundry.deploy.lib.exceptions import (
15
- BadRequestException,
16
16
  ConfigurationException,
17
17
  )
18
18
  from truefoundry.deploy.lib.util import is_debug_env_set
@@ -66,7 +66,7 @@ class RemoteClass(Remote):
66
66
  # methods in the class, but internally doing network call.
67
67
  # But I am sticking with this now because not all the concepts of a python
68
68
  # class right now, will work in both remote and local. Examples, you cannot
69
- # access arbitary attributes, properties etc. I want to keep the behaviour
69
+ # access arbitrary attributes, properties etc. I want to keep the behaviour
70
70
  # identical for now.
71
71
  absent = object()
72
72
  methods = inspect.getmembers(class_, predicate=inspect.isfunction)
@@ -2,12 +2,12 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Optional
4
4
 
5
- from truefoundry.deploy.lib.auth.credential_provider import (
5
+ from truefoundry.common.credential_provider import (
6
6
  CredentialProvider,
7
7
  EnvCredentialProvider,
8
8
  FileCredentialProvider,
9
9
  )
10
- from truefoundry.deploy.lib.model.entity import UserInfo
10
+ from truefoundry.common.entities import UserInfo
11
11
  from truefoundry.logger import logger
12
12
 
13
13
  ACTIVE_SESSION: Optional[ServiceFoundrySession] = None