truefoundry 0.6.3rc3__py3-none-any.whl → 0.6.4__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.

truefoundry/__init__.py CHANGED
@@ -14,6 +14,7 @@ from truefoundry.common.warnings import (
14
14
  surface_truefoundry_deprecation_warnings,
15
15
  )
16
16
  from truefoundry.deploy.core import login, logout
17
+ from truefoundry.ml.prompt_utils import render_prompt
17
18
 
18
19
  surface_truefoundry_deprecation_warnings()
19
20
  __all__ = [
@@ -25,6 +26,7 @@ __all__ = [
25
26
  "ModelConfiguration",
26
27
  "Parameters",
27
28
  "PromptVersion",
29
+ "render_prompt",
28
30
  "suppress_truefoundry_deprecation_warnings",
29
31
  "SystemMessage",
30
32
  "UserMessage",
@@ -112,6 +112,9 @@ from truefoundry.deploy.v2.lib.patched_models import (
112
112
  SecretMount,
113
113
  ServiceAutoscaling,
114
114
  SlackWebhook,
115
+ SparkJobJavaEntrypoint,
116
+ SparkJobPythonEntrypoint,
117
+ SparkJobScalaEntrypoint,
115
118
  SQSInputConfig,
116
119
  SQSOutputConfig,
117
120
  SQSQueueMetricConfig,
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: application.json
3
- # timestamp: 2025-03-27T11:40:57+00:00
3
+ # timestamp: 2025-04-07T11:22:45+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -282,9 +282,9 @@ class GitSource(BaseModel):
282
282
  """
283
283
 
284
284
  type: Literal["git"] = Field(..., description="")
285
- repo_url: constr(
286
- regex=r"^(http(s?)://)(github\.com|(.+@)*bitbucket\.org|gitlab\.com|(.*)@dev.azure.com).*$"
287
- ) = Field(..., description="The repository URL.")
285
+ repo_url: constr(regex=r"^(https?://)\S+$") = Field(
286
+ ..., description="The repository URL."
287
+ )
288
288
  ref: str = Field(..., description="The commit SHA.")
289
289
  branch_name: Optional[str] = Field(
290
290
  None,
@@ -856,6 +856,42 @@ class SparkExecutorFixedInstances(BaseModel):
856
856
  count: conint(ge=0, le=500) = Field(1, description="Number of instances to start")
857
857
 
858
858
 
859
+ class SparkJobJavaEntrypoint(BaseModel):
860
+ type: Literal["java"] = Field(..., description="")
861
+ main_application_file: str = Field(
862
+ ..., description="The main application file to be executed by the spark job."
863
+ )
864
+ main_class: str = Field(
865
+ ..., description="The main class to be executed by the spark job."
866
+ )
867
+ arguments: Optional[str] = Field(
868
+ None, description="Arguments to be passed to the main application file."
869
+ )
870
+
871
+
872
+ class SparkJobPythonEntrypoint(BaseModel):
873
+ type: Literal["python"] = Field(..., description="")
874
+ main_application_file: str = Field(
875
+ ..., description="The main application file to be executed by the spark job."
876
+ )
877
+ arguments: Optional[str] = Field(
878
+ None, description="Arguments to be passed to the main application file."
879
+ )
880
+
881
+
882
+ class SparkJobScalaEntrypoint(BaseModel):
883
+ type: Literal["scala"] = Field(..., description="")
884
+ main_application_file: str = Field(
885
+ ..., description="The main application file to be executed by the spark job."
886
+ )
887
+ main_class: str = Field(
888
+ ..., description="The main class to be executed by the spark job."
889
+ )
890
+ arguments: Optional[str] = Field(
891
+ None, description="Arguments to be passed to the main application file."
892
+ )
893
+
894
+
859
895
  class StaticVolumeConfig(BaseModel):
860
896
  type: Literal["static"] = Field(..., description="Volume Type for the volume.")
861
897
  persistent_volume_name: str = Field(
@@ -1349,24 +1385,21 @@ class SparkJob(BaseModel):
1349
1385
  name: constr(regex=r"^[a-z](?:[a-z0-9]|-(?!-)){1,30}[a-z0-9]$") = Field(
1350
1386
  ..., description="Name of the job"
1351
1387
  )
1388
+ entrypoint: Union[
1389
+ SparkJobPythonEntrypoint, SparkJobScalaEntrypoint, SparkJobJavaEntrypoint
1390
+ ] = Field(..., description="")
1352
1391
  image: Image
1353
1392
  spark_version: str = Field(
1354
1393
  "3.5.2",
1355
1394
  description="Spark version should match the spark version installed in the image.",
1356
1395
  )
1357
- main_application_file: str = Field(
1358
- ..., description="The main application file to be executed by the spark job."
1359
- )
1360
- arguments: Optional[str] = Field(
1361
- None, description="Arguments to be passed to the main application file."
1362
- )
1363
1396
  driver_config: SparkDriverConfig
1364
1397
  executor_config: SparkExecutorConfig
1365
1398
  env: Optional[Dict[str, Any]] = Field(
1366
1399
  None,
1367
1400
  description="Configure environment variables to be injected in the service either as plain text. [Docs](https://docs.truefoundry.com/docs/env-variables)",
1368
1401
  )
1369
- conf: Optional[Dict[str, Any]] = Field(
1402
+ spark_conf: Optional[Dict[str, Any]] = Field(
1370
1403
  None,
1371
1404
  description="Extra configuration properties to be passed to the spark job. [Docs](https://spark.apache.org/docs/latest/configuration.html)",
1372
1405
  )
@@ -571,3 +571,15 @@ class Email(models.Email, PatchedModelBase):
571
571
 
572
572
  class SlackWebhook(models.SlackWebhook, PatchedModelBase):
573
573
  type: Literal["slack-webhook"] = "slack-webhook"
574
+
575
+
576
+ class SparkJobScalaEntrypoint(models.SparkJobScalaEntrypoint, PatchedModelBase):
577
+ type: Literal["scala"] = "scala"
578
+
579
+
580
+ class SparkJobPythonEntrypoint(models.SparkJobPythonEntrypoint, PatchedModelBase):
581
+ type: Literal["python"] = "python"
582
+
583
+
584
+ class SparkJobJavaEntrypoint(models.SparkJobJavaEntrypoint, PatchedModelBase):
585
+ type: Literal["java"] = "java"
@@ -0,0 +1,65 @@
1
+ import re
2
+ from typing import Any, Dict, Optional
3
+
4
+ from truefoundry_sdk import ChatPromptManifest
5
+
6
+ _VAR_PATTERN = re.compile(r"\{\{(\w+)\}\}")
7
+
8
+
9
+ def render_text(template: str, variables: Dict[str, str]) -> str:
10
+ return _VAR_PATTERN.sub(
11
+ lambda m: (variables.get(m.group(1), f"{{{{{m.group(1)}}}}}")), template
12
+ )
13
+
14
+
15
+ def render_prompt(
16
+ prompt_template: ChatPromptManifest, variables: Optional[Dict[str, str]] = None
17
+ ) -> Dict[str, Any]:
18
+ """
19
+ Renders a prompt template with the provided variables.
20
+ Args:
21
+ prompt_template (ChatPromptManifest): The prompt template to render.
22
+ variables (Optional[Dict[str, str]]): A dictionary of variables to replace in the template.
23
+ If None, the default variables from the prompt template will be used.
24
+
25
+ Returns:
26
+ Dict[str, Any]: A dictionary containing the rendered messages and model configuration.
27
+
28
+ """
29
+ # Render the messages in the prompt template with the provided variables and default variables
30
+ rendered_messages = []
31
+ variables = {**(prompt_template.variables or {}), **(variables or {})}
32
+ messages = [message.copy(deep=True) for message in prompt_template.messages]
33
+
34
+ # Render the messages with the provided variables, if any
35
+ if variables:
36
+ for msg in messages:
37
+ if isinstance(msg.content, str):
38
+ msg.content = render_text(template=msg.content, variables=variables)
39
+ elif isinstance(msg.content, list):
40
+ for part in msg.content:
41
+ if part.type == "image_url" and isinstance(part.image_url.url, str):
42
+ part.image_url.url = render_text(
43
+ part.image_url.url, variables=variables
44
+ )
45
+ elif part.type == "text" and isinstance(part.text, str):
46
+ part.text = render_text(part.text, variables=variables)
47
+
48
+ rendered_messages = [message.dict() for message in messages]
49
+
50
+ # Merge parameters from model_configuration and extra_parameters
51
+ model_configuration = prompt_template.model_configuration
52
+ parameters = {
53
+ **(
54
+ model_configuration.parameters.dict()
55
+ if model_configuration.parameters
56
+ else {}
57
+ ),
58
+ **(model_configuration.extra_parameters or {}),
59
+ }
60
+
61
+ return {
62
+ "messages": rendered_messages,
63
+ "model": model_configuration.model,
64
+ "parameters": parameters,
65
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: truefoundry
3
- Version: 0.6.3rc3
3
+ Version: 0.6.4
4
4
  Summary: TrueFoundry CLI
5
5
  Author-email: TrueFoundry Team <abhishek@truefoundry.com>
6
6
  Requires-Python: <3.14,>=3.8.1
@@ -30,7 +30,7 @@ Requires-Dist: requirements-parser<0.12.0,>=0.11.0
30
30
  Requires-Dist: rich-click<2.0.0,>=1.2.1
31
31
  Requires-Dist: rich<14.0.0,>=13.7.1
32
32
  Requires-Dist: tqdm<5.0.0,>=4.0.0
33
- Requires-Dist: truefoundry-sdk==0.0.8
33
+ Requires-Dist: truefoundry-sdk==0.0.10
34
34
  Requires-Dist: typing-extensions>=4.0
35
35
  Requires-Dist: urllib3<3,>=1.26.18
36
36
  Requires-Dist: yq<4.0.0,>=3.1.0
@@ -1,4 +1,4 @@
1
- truefoundry/__init__.py,sha256=eRH4vd0dZTwSLl91MZ99yhI9b-lcC_XQQZRxN-srzms,703
1
+ truefoundry/__init__.py,sha256=_Ty6ohIytSuJfQDEC7mCKW0aBEb6bAI2pRDi01haAnU,778
2
2
  truefoundry/_client.py,sha256=Y3qHi_Lg4Sx6GNvsjAHIoAfFr8PJnqgCrXmpNAI3ECg,1417
3
3
  truefoundry/logger.py,sha256=u-YCNjg5HBwE70uQcpjIG64Ghos-K2ulTWaxC03BSj4,714
4
4
  truefoundry/pydantic_v1.py,sha256=jSuhGtz0Mbk1qYu8jJ1AcnIDK4oxUsdhALc4spqstmM,345
@@ -48,9 +48,9 @@ truefoundry/common/storage_provider_utils.py,sha256=yURhMw8k0FLFvaviRHDiifhvc6Gn
48
48
  truefoundry/common/types.py,sha256=BMJFCsR1lPJAw66IQBSvLyV4I6o_x5oj78gVsUa9si8,188
49
49
  truefoundry/common/utils.py,sha256=yEQtJW2fT9xbNpRhfRoD9hvhGw-FgGS3agh1oZptmjg,6379
50
50
  truefoundry/common/warnings.py,sha256=rs6BHwk7imQYedo07iwh3TWEOywAR3Lqhj0AY4khByg,504
51
- truefoundry/deploy/__init__.py,sha256=zNsyzJAOPCPqlhVEEq6sBpfPsa4XkChaXvE-EBCmfzs,2645
51
+ truefoundry/deploy/__init__.py,sha256=SkkhHRP1qOeQb1XYRiTKKjA0uDm8YEbdDEPUN4rvY1w,2732
52
52
  truefoundry/deploy/python_deploy_codegen.py,sha256=AainOFR20XvhNeztJkLPWGZ40lAT_nwc-ZmG77Kum4o,6525
53
- truefoundry/deploy/_autogen/models.py,sha256=0m43YJVG0fBhLp0fPkCod_vIcMFob0jTQEGnjk6nOUQ,69804
53
+ truefoundry/deploy/_autogen/models.py,sha256=rypFsppVuXJJOhFwYAS65Ef3OyIPTkBIod9DXoDwOwY,70918
54
54
  truefoundry/deploy/builder/__init__.py,sha256=nGQiR3r16iumRy7xbVQ6q-k0EApmijspsfVpXDE-9po,4953
55
55
  truefoundry/deploy/builder/constants.py,sha256=amUkHoHvVKzGv0v_knfiioRuKiJM0V0xW0diERgWiI0,508
56
56
  truefoundry/deploy/builder/docker_service.py,sha256=sm7GWeIqyrKaZpxskdLejZlsxcZnM3BTDJr6orvPN4E,3948
@@ -108,7 +108,7 @@ truefoundry/deploy/v2/lib/deploy.py,sha256=FWmqX4N6RUN4-S68i-7xaIifYWnf0wc-zfINd
108
108
  truefoundry/deploy/v2/lib/deploy_workflow.py,sha256=G5BzMIbap8pgDX1eY-TITruUxQdkKhYtBmRwLL6lDeY,14342
109
109
  truefoundry/deploy/v2/lib/deployable_patched_models.py,sha256=xbHFD3pURflvCm8EODPvjfvRrv67mlSrjPUknY8SMB8,4060
110
110
  truefoundry/deploy/v2/lib/models.py,sha256=ogc1UYs1Z2nBdGSKCrde9sk8d0GxFKMkem99uqO5CmM,1148
111
- truefoundry/deploy/v2/lib/patched_models.py,sha256=vVjYs1Gm7mpuTx3C0l40RQ_zvMdQ1S0s6J-f00qO0nA,16557
111
+ truefoundry/deploy/v2/lib/patched_models.py,sha256=xlgFust2rSnPfQcSe2SW0Sl4gShvZnZNf1UFKjUkPI0,16917
112
112
  truefoundry/deploy/v2/lib/source.py,sha256=d6-8_6Zn5koBglqrBrY6ZLG_7yyPuLdyEmK4iZTw6xY,9405
113
113
  truefoundry/ml/__init__.py,sha256=EEEHV7w58Krpo_W9Chd8Y3TdItfFO3LI6j6Izqc4-P8,2219
114
114
  truefoundry/ml/constants.py,sha256=vDq72d4C9FSWqr9MMdjgTF4TuyNFApvo_6RVsSeAjB4,2837
@@ -121,6 +121,7 @@ truefoundry/ml/logger.py,sha256=VT-BF3BnBYTWVq87O58F0c8uXMu94gYzsiFlGY3_7Ao,458
121
121
  truefoundry/ml/mlfoundry_api.py,sha256=WiIVpJRylBn8NrcAmXClQnavffqI9fhY5h-8Vwx4RKo,59872
122
122
  truefoundry/ml/mlfoundry_run.py,sha256=34yyQqgpG6EfrAJd37vkbCjrFoHkhvbOAxxSQcSWPtY,44320
123
123
  truefoundry/ml/model_framework.py,sha256=nVbKTtKDRBdLzt7Wrg5_vJKZ-awHbISGvL73s-V9egU,18975
124
+ truefoundry/ml/prompt_utils.py,sha256=K5CnHKcxciHD20gtxAvuGAoLc08NwjOB5gxDvlkroxc,2470
124
125
  truefoundry/ml/run_utils.py,sha256=0W208wSLUrbdfk2pjNcZlkUi9bNxG2JORqoe-5rVqHI,2423
125
126
  truefoundry/ml/session.py,sha256=2v8JjFyrcKzKQ8qsTaZaQTqlxl-in9odIMyWWMEqWNY,4436
126
127
  truefoundry/ml/validation_utils.py,sha256=rmIBNcpmnwq2jeje6uFg8uY-rL4JG_RV6mc6BlujVWg,12150
@@ -371,7 +372,7 @@ truefoundry/workflow/remote_filesystem/__init__.py,sha256=LQ95ViEjJ7Ts4JcCGOxMPs
371
372
  truefoundry/workflow/remote_filesystem/logger.py,sha256=em2l7D6sw7xTLDP0kQSLpgfRRCLpN14Qw85TN7ujQcE,1022
372
373
  truefoundry/workflow/remote_filesystem/tfy_signed_url_client.py,sha256=xcT0wQmQlgzcj0nP3tJopyFSVWT1uv3nhiTIuwfXYeg,12342
373
374
  truefoundry/workflow/remote_filesystem/tfy_signed_url_fs.py,sha256=nSGPZu0Gyd_jz0KsEE-7w_BmnTD8CVF1S8cUJoxaCbc,13305
374
- truefoundry-0.6.3rc3.dist-info/METADATA,sha256=8e9-fba9S4VCR0DjKElwUVf4lKqOaZ15Ua-f4N6jKU8,2352
375
- truefoundry-0.6.3rc3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
376
- truefoundry-0.6.3rc3.dist-info/entry_points.txt,sha256=xVjn7RMN-MW2-9f7YU-bBdlZSvvrwzhpX1zmmRmsNPU,98
377
- truefoundry-0.6.3rc3.dist-info/RECORD,,
375
+ truefoundry-0.6.4.dist-info/METADATA,sha256=Zlf3TokDrDXPIDuTfabZ5A9jv6fegUeVYE3bntGuaaU,2350
376
+ truefoundry-0.6.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
377
+ truefoundry-0.6.4.dist-info/entry_points.txt,sha256=xVjn7RMN-MW2-9f7YU-bBdlZSvvrwzhpX1zmmRmsNPU,98
378
+ truefoundry-0.6.4.dist-info/RECORD,,