flyteplugins-codegen 2.1.8__py3-none-any.whl → 2.2.0__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.
@@ -12,7 +12,7 @@ import flyte
12
12
  import litellm
13
13
  import pandas as pd
14
14
  from flyte.errors import InvalidPackageError
15
- from flyte.io import File
15
+ from flyte.io import Dir, File
16
16
  from flyte.sandbox import ImageConfig
17
17
  from flyte.syncify import syncify
18
18
 
@@ -150,9 +150,9 @@ class AutoCoderAgent:
150
150
  inputs: Optional dict declaring non-sample CLI argument types
151
151
  (e.g., `{"threshold": float, "mode": str}`).
152
152
  Sample entries are automatically added as File inputs — don't redeclare them here.
153
- Supported types: str, int, float, bool, File.
153
+ Supported types: str, int, float, bool, File, Dir.
154
154
  outputs: Optional dict defining output types (e.g., `{"result": str, "report": File}`).
155
- Supported types: str, int, float, bool, datetime, timedelta, File.
155
+ Supported types: str, int, float, bool, datetime, timedelta, File, Dir.
156
156
 
157
157
  Returns:
158
158
  CodeGenEvalResult with solution and execution details.
@@ -161,7 +161,7 @@ class AutoCoderAgent:
161
161
 
162
162
  # Input validation
163
163
  if inputs:
164
- supported_input_types = (str, int, float, bool, File)
164
+ supported_input_types = (str, int, float, bool, File, Dir)
165
165
  for input_key, input_type in inputs.items():
166
166
  if input_type not in supported_input_types:
167
167
  supported_names = [t.__name__ for t in supported_input_types]
@@ -238,6 +238,7 @@ class AutoCoderAgent:
238
238
  datetime.datetime,
239
239
  datetime.timedelta,
240
240
  File,
241
+ Dir,
241
242
  )
242
243
  for output_key, output_type in outputs.items():
243
244
  if output_type not in supported_types:
@@ -2,6 +2,8 @@
2
2
 
3
3
  from typing import Optional
4
4
 
5
+ from flyte.io import Dir, File
6
+
5
7
  # Language-specific file extensions
6
8
  FILE_EXTENSIONS = {"python": ".py"}
7
9
 
@@ -70,6 +72,9 @@ def build_enhanced_prompt(
70
72
  if schema:
71
73
  enhanced_prompt += f"\n\nSchema:\n``\n{schema}\n``"
72
74
 
75
+ def _is_path_input_type(param_type: type) -> bool:
76
+ return param_type in (File, Dir) or any(name in str(param_type) for name in ("File", "Dir"))
77
+
73
78
  # Always add script requirement first, then user constraints
74
79
  script_constraint = (
75
80
  "REQUIRED: Your code will be saved as solution.py and imported by tests via "
@@ -85,19 +90,20 @@ def build_enhanced_prompt(
85
90
  args_list = []
86
91
  for name, param_type in inputs.items():
87
92
  type_name = param_type.__name__ if hasattr(param_type, "__name__") else str(param_type)
88
- # Clarify that File inputs are received as string paths
89
- if "File" in type_name:
93
+ # Clarify that File/Dir inputs are received as string paths
94
+ if _is_path_input_type(param_type):
90
95
  args_list.append(f"--{name} (str): path to {type_name.lower()}")
91
96
  else:
92
97
  args_list.append(f"--{name} ({type_name})")
93
98
  args_spec = ", ".join(args_list)
94
99
  script_constraint += f"Accept these command line arguments: {args_spec}. "
95
100
 
96
- # Add explicit instruction for File handling
97
- has_file_inputs = any("File" in str(t) for t in inputs.values())
98
- if has_file_inputs:
101
+ # Add explicit instruction for File/Dir handling
102
+ has_path_inputs = any(_is_path_input_type(t) for t in inputs.values())
103
+ if has_path_inputs:
99
104
  script_constraint += (
100
- "File arguments are string paths - use them directly with open() or other file operations."
105
+ "File and Dir arguments are string paths - use them directly with "
106
+ "open(), pathlib, or other file operations."
101
107
  )
102
108
  elif data_context:
103
109
  script_constraint += "Accept appropriate command line arguments to process the data samples."
@@ -111,16 +117,20 @@ def build_enhanced_prompt(
111
117
  output_parts = []
112
118
  for name, output_type in outputs.items():
113
119
  type_name = output_type.__name__ if hasattr(output_type, "__name__") else str(output_type)
114
- if "File" in type_name:
120
+ if output_type is Dir or "Dir" in type_name:
121
+ output_parts.append(f"- {name}: create the output directory directly at /var/outputs/{name}")
122
+ elif _is_path_input_type(output_type):
115
123
  output_parts.append(f"- {name}: write the output file directly to /var/outputs/{name}")
116
124
  else:
117
125
  output_parts.append(f"- {name} ({type_name}): write the value to /var/outputs/{name}")
118
126
  output_list = "\n".join(output_parts)
119
127
  output_constraint = f"""OUTPUT REQUIREMENTS — you MUST write each output as a file under /var/outputs/:
120
128
  {output_list}
121
- Use this exact pattern for each output:
129
+ Use this exact pattern for scalar outputs:
122
130
  with open('/var/outputs/<name>', 'w') as f:
123
131
  f.write(str(value))
132
+ For File outputs, write the file directly to /var/outputs/<name>.
133
+ For Dir outputs, create the directory directly at /var/outputs/<name>.
124
134
  /var/outputs/ already exists. NEVER delete, recreate, or modify the directory itself. Only write files into it.
125
135
  Outputs MUST be written before the script exits — do NOT just print() values."""
126
136
  all_constraints.append(output_constraint)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flyteplugins-codegen
3
- Version: 2.1.8
3
+ Version: 2.2.0
4
4
  Summary: LLM-powered code generation and evaluation plugin for Flyte
5
5
  Author-email: Samhita Alla <samhita@union.ai>
6
6
  Requires-Python: >=3.10
@@ -188,8 +188,8 @@ result = await agent.generate.aio(prompt="...")
188
188
  | `schema` | `str` | `None` | Free-form context about data formats, structures, or schemas. Included verbatim in the LLM prompt. |
189
189
  | `constraints` | `list[str]` | `None` | Natural-language constraints (e.g., `"quantity must be positive"`) |
190
190
  | `samples` | `dict[str, File \| pd.DataFrame]` | `None` | Sample data. Sampled for LLM context, converted to File inputs for the sandbox. Used as defaults at runtime. |
191
- | `inputs` | `dict[str, type]` | `None` | Non-sample CLI argument types (e.g., `{"threshold": float}`). Sample entries are auto-added as File inputs. |
192
- | `outputs` | `dict[str, type]` | `None` | Output types. Supported: `str, int, float, bool, datetime, timedelta, File`. |
191
+ | `inputs` | `dict[str, type]` | `None` | Non-sample CLI argument types (e.g., `{"threshold": float}`). Sample entries are auto-added as File inputs. Supported: `str, int, float, bool, File, Dir`. |
192
+ | `outputs` | `dict[str, type]` | `None` | Output types. Supported: `str, int, float, bool, datetime, timedelta, File, Dir`. |
193
193
 
194
194
  ### `CodeGenEvalResult`
195
195
 
@@ -1,5 +1,5 @@
1
1
  flyteplugins/codegen/__init__.py,sha256=jumoM0Po0Tx1KqatcdNi_Mk1MYCLcccnyjn6d1zurLQ,366
2
- flyteplugins/codegen/auto_coder_agent.py,sha256=-HkI3nM3T0Ydj8ezDprDI8DLetgQeoixBDGJXnJfmUA,46241
2
+ flyteplugins/codegen/auto_coder_agent.py,sha256=G6F4OCJXKU-6Y16hNdodu8FtOVrOsdt2hI-lNHF40Ac,46282
3
3
  flyteplugins/codegen/core/__init__.py,sha256=YjAN0PpvkhERFmlkEq78O2q92bmgyGAVttYXeDH_hyc,355
4
4
  flyteplugins/codegen/core/types.py,sha256=kxAoKMu9tOTRNPBfiFC-dxMQOmeEawJAVRNKj42_3js,12274
5
5
  flyteplugins/codegen/data/__init__.py,sha256=UDkKuvyBEZmsPaTR6yEexcQjLutMRxuV5-pWflGc_sI,670
@@ -10,8 +10,8 @@ flyteplugins/codegen/execution/agent.py,sha256=eCIsQ09YU3OYRci1dZb8lRqxTPr21DHvW
10
10
  flyteplugins/codegen/execution/docker.py,sha256=LSmg9g7MCiD-yGAMuQT0YCh_npma_dellSh0WIvJHak,7294
11
11
  flyteplugins/codegen/generation/__init__.py,sha256=GkLiXfJeVQmLlHf4R08qzgUa5wYG97KseGjRtLCFZhU,1065
12
12
  flyteplugins/codegen/generation/llm.py,sha256=FPBt1MlW_OjwtEEcnJhE62sYrbSK4tRB3UEk80cWvgQ,44229
13
- flyteplugins/codegen/generation/prompts.py,sha256=Te9nK9TldLyHM2KB24PhTiWNqoEXJlW9l8nt09FbWa8,5770
14
- flyteplugins_codegen-2.1.8.dist-info/METADATA,sha256=VUaHhiLQdeQxOOj6dK_e6SdWXYsnxN9NnBhYLbNsZTY,19203
15
- flyteplugins_codegen-2.1.8.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
- flyteplugins_codegen-2.1.8.dist-info/top_level.txt,sha256=cgd779rPu9EsvdtuYgUxNHHgElaQvPn74KhB5XSeMBE,13
17
- flyteplugins_codegen-2.1.8.dist-info/RECORD,,
13
+ flyteplugins/codegen/generation/prompts.py,sha256=-Qt8M_6bkS4Jwm-bCQnCGR-oKL_mWhryCc9_OUnvXPs,6344
14
+ flyteplugins_codegen-2.2.0.dist-info/METADATA,sha256=FMQo2zFmKhNgTnGyAoWvwTtiYDkq45cQPwhWVDD56y4,19246
15
+ flyteplugins_codegen-2.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
+ flyteplugins_codegen-2.2.0.dist-info/top_level.txt,sha256=cgd779rPu9EsvdtuYgUxNHHgElaQvPn74KhB5XSeMBE,13
17
+ flyteplugins_codegen-2.2.0.dist-info/RECORD,,