weco 0.2.3__py3-none-any.whl → 0.2.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.
weco/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # DO NOT EDIT
2
- __pkg_version__ = "0.2.3"
2
+ __pkg_version__ = "0.2.4"
3
3
  __api_version__ = "v1"
4
4
  __base_url__ = f"https://api.aide.weco.ai/{__api_version__}"
weco/cli.py CHANGED
@@ -104,54 +104,59 @@ def main() -> None:
104
104
  api_keys=api_keys,
105
105
  )
106
106
 
107
- # Define the runs directory (.runs/<session-id>)
108
- session_id = session_response["session_id"]
109
- runs_dir = pathlib.Path(".runs") / session_id
110
- runs_dir.mkdir(parents=True, exist_ok=True)
111
-
112
- # Save the original code (.runs/<session-id>/original.py)
113
- runs_copy_source_fp = runs_dir / "original.py"
114
- write_to_path(fp=runs_copy_source_fp, content=source_code)
115
-
116
- # Write the code string to the source file path
117
- # Do this after the original code is saved
118
- write_to_path(fp=source_fp, content=session_response["code"])
119
-
120
- # Update the panels with the initial solution
121
- # Add session id now that we have it
122
- summary_panel.session_id = session_id
123
- # Set the step of the progress bar
124
- summary_panel.set_step(step=0)
125
- # Update the token counts
126
- summary_panel.update_token_counts(usage=session_response["usage"])
127
- # Update the plan
128
- plan_panel.update(plan=session_response["plan"])
129
- # Build the metric tree
130
- tree_panel.build_metric_tree(
131
- nodes=[
132
- {
133
- "solution_id": session_response["solution_id"],
134
- "parent_id": None,
135
- "code": session_response["code"],
136
- "step": 0,
137
- "metric_value": None,
138
- "is_buggy": False,
139
- }
140
- ]
141
- )
142
- # Set the current solution as unevaluated since we haven't run the evaluation function and fed it back to the model yet
143
- tree_panel.set_unevaluated_node(node_id=session_response["solution_id"])
144
- # Update the solution panels with the initial solution and get the panel displays
145
- solution_panels.update(
146
- current_node=Node(
147
- id=session_response["solution_id"], parent_id=None, code=session_response["code"], metric=None, is_buggy=False
148
- ),
149
- best_node=None,
150
- )
151
- current_solution_panel, best_solution_panel = solution_panels.get_display(current_step=0)
152
107
  # Define the refresh rate
153
108
  refresh_rate = 4
154
109
  with Live(layout, refresh_per_second=refresh_rate, screen=True) as live:
110
+ # Define the runs directory (.runs/<session-id>)
111
+ session_id = session_response["session_id"]
112
+ runs_dir = pathlib.Path(".runs") / session_id
113
+ runs_dir.mkdir(parents=True, exist_ok=True)
114
+
115
+ # Save the original code (.runs/<session-id>/original.py)
116
+ runs_copy_source_fp = runs_dir / "original.py"
117
+ write_to_path(fp=runs_copy_source_fp, content=source_code)
118
+
119
+ # Write the code string to the source file path
120
+ # Do this after the original code is saved
121
+ write_to_path(fp=source_fp, content=session_response["code"])
122
+
123
+ # Update the panels with the initial solution
124
+ # Add session id now that we have it
125
+ summary_panel.session_id = session_id
126
+ # Set the step of the progress bar
127
+ summary_panel.set_step(step=0)
128
+ # Update the token counts
129
+ summary_panel.update_token_counts(usage=session_response["usage"])
130
+ # Update the plan
131
+ plan_panel.update(plan=session_response["plan"])
132
+ # Build the metric tree
133
+ tree_panel.build_metric_tree(
134
+ nodes=[
135
+ {
136
+ "solution_id": session_response["solution_id"],
137
+ "parent_id": None,
138
+ "code": session_response["code"],
139
+ "step": 0,
140
+ "metric_value": None,
141
+ "is_buggy": False,
142
+ }
143
+ ]
144
+ )
145
+ # Set the current solution as unevaluated since we haven't run the evaluation function and fed it back to the model yet
146
+ tree_panel.set_unevaluated_node(node_id=session_response["solution_id"])
147
+ # Update the solution panels with the initial solution and get the panel displays
148
+ solution_panels.update(
149
+ current_node=Node(
150
+ id=session_response["solution_id"],
151
+ parent_id=None,
152
+ code=session_response["code"],
153
+ metric=None,
154
+ is_buggy=False,
155
+ ),
156
+ best_node=None,
157
+ )
158
+ current_solution_panel, best_solution_panel = solution_panels.get_display(current_step=0)
159
+
155
160
  # Update the entire layout
156
161
  smooth_update(
157
162
  live=live,
weco/panels.py CHANGED
@@ -12,7 +12,7 @@ class SummaryPanel:
12
12
  """Holds a summary of the optimization session."""
13
13
 
14
14
  def __init__(self, maximize: bool, metric_name: str, total_steps: int, model: str, session_id: str = None):
15
- self.goal = ("Maximizing" if maximize else "Minimizing") + f" {metric_name}"
15
+ self.goal = ("Maximizing" if maximize else "Minimizing") + f" {metric_name}..."
16
16
  self.total_input_tokens = 0
17
17
  self.total_output_tokens = 0
18
18
  self.total_steps = total_steps
@@ -48,10 +48,10 @@ class SummaryPanel:
48
48
  summary_table.add_row("")
49
49
  # Log directory
50
50
  runs_dir = f".runs/{self.session_id}"
51
- summary_table.add_row(f"[bold cyan]Logs:[/] [blue]{runs_dir}[/]")
51
+ summary_table.add_row(f"[bold cyan]Logs:[/] [blue underline]{runs_dir}[/]")
52
52
  summary_table.add_row("")
53
53
  # Model used
54
- summary_table.add_row(f"[bold cyan]Model:[/] {self.model}")
54
+ summary_table.add_row(f"[bold cyan]Model:[/] [yellow]{self.model}[/]")
55
55
  summary_table.add_row("")
56
56
  # Token counts
57
57
  summary_table.add_row(
@@ -197,7 +197,7 @@ class MetricTreePanel:
197
197
  # best node
198
198
  color = "green"
199
199
  style = "bold"
200
- text = f"🏆 {node.metric:.3f}"
200
+ text = f"{node.metric:.3f} 🏆"
201
201
  elif node.metric is None:
202
202
  # metric not extracted from evaluated solution
203
203
  color = "yellow"
@@ -214,7 +214,7 @@ class MetricTreePanel:
214
214
  for child in node.children:
215
215
  append_rec(child, subtree)
216
216
 
217
- tree = Tree("solutions")
217
+ tree = Tree("🌳")
218
218
  for n in self.metric_tree.get_draft_nodes():
219
219
  append_rec(n, tree)
220
220
 
@@ -223,7 +223,9 @@ class MetricTreePanel:
223
223
  def get_display(self) -> Panel:
224
224
  """Get a panel displaying the solution tree."""
225
225
  # Make sure the metric tree is built before calling build_rich_tree
226
- return Panel(self._build_rich_tree(), title="[bold]🌳 Exploring...", border_style="green", expand=True, padding=(0, 1))
226
+ return Panel(
227
+ self._build_rich_tree(), title="[bold]🔎 Exploring Solutions...", border_style="green", expand=True, padding=(0, 1)
228
+ )
227
229
 
228
230
 
229
231
  class EvaluationOutputPanel:
@@ -242,7 +244,7 @@ class EvaluationOutputPanel:
242
244
 
243
245
  def get_display(self) -> Panel:
244
246
  """Create a panel displaying the evaluation output with truncation if needed."""
245
- return Panel(self.output, title="[bold]📋 Evaluation Output", border_style="red", expand=True, padding=(0, 1))
247
+ return Panel(self.output, title="[bold]📋 Evaluation Output", border_style="blue", expand=True, padding=(0, 1))
246
248
 
247
249
 
248
250
  class SolutionPanels:
weco/utils.py CHANGED
@@ -28,10 +28,14 @@ def read_additional_instructions(additional_instructions: str | None) -> str | N
28
28
 
29
29
  # Try interpreting as a path first
30
30
  potential_path = pathlib.Path(additional_instructions)
31
- if potential_path.exists() and potential_path.is_file():
32
- return read_from_path(potential_path, is_json=False) # type: ignore # read_from_path returns str when is_json=False
33
- else:
34
- # If it's not a valid file path, return the string itself
31
+ try:
32
+ if potential_path.exists() and potential_path.is_file():
33
+ return read_from_path(potential_path, is_json=False) # type: ignore # read_from_path returns str when is_json=False
34
+ else:
35
+ # If it's not a valid file path, return the string itself
36
+ return additional_instructions
37
+ except OSError:
38
+ # If the path can't be read, return the string itself
35
39
  return additional_instructions
36
40
 
37
41
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weco
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
5
5
  Author-email: Weco AI Team <dhruv@weco.ai>
6
6
  License: MIT
@@ -88,19 +88,19 @@ weco --source examples/simple-torch/optimize.py \
88
88
  --metric speedup \
89
89
  --maximize true \
90
90
  --steps 15 \
91
- --model "o3-mini" \
91
+ --model o3-mini \
92
92
  --additional-instructions "Fuse operations in the forward method while ensuring the max float deviation remains small. Maintain the same format of the code."
93
93
  ```
94
94
 
95
- Optimizing these same using mlx and metal:
95
+ Sometimes we have a bit more context we'd like to provide. Its not easy to fit all of this in a string like shown above with `additional-instructions`. Thats why you can also provide a path to any file you'd like to me read as in context. In this example, we optimize the same operations using mlx and metal with additional instructions:
96
96
  ```bash
97
97
  weco --source examples/simple-mlx/optimize.py \
98
98
  --eval-command "python examples/simple-mlx/evaluate.py --solution-path examples/simple-mlx/optimize.py" \
99
99
  --metric speedup \
100
100
  --maximize true \
101
101
  --steps 30 \
102
- --model "o3-mini" \
103
- --additional-instructions "examples/simple-mlx/metal-examples.rst"
102
+ --model o3-mini \
103
+ --additional-instructions examples/simple-mlx/metal-examples.rst
104
104
  ```
105
105
  ---
106
106
 
@@ -0,0 +1,11 @@
1
+ weco/__init__.py,sha256=5TUzMXAo2-PEbB3T_z4hNMJpe1yYKi36KZIeo5s1TCI,124
2
+ weco/api.py,sha256=JHAm60sO51Y2tzLnyAAFv9OLm75o_RNWeoK-gYF4VHE,3342
3
+ weco/cli.py,sha256=daKXAnwjnvUptaVA8nShzJiO9piU91c24s294rzu2d4,16492
4
+ weco/panels.py,sha256=5HrDrYzx_vDjV41mlZmOOZYxdJIXD5RzBBNKXxUOLEY,12022
5
+ weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
6
+ weco-0.2.4.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
+ weco-0.2.4.dist-info/METADATA,sha256=T2f_Fa3CdnfX1nwPFCbpY6a3lGYWx5BudSw4lcKxdCg,5518
8
+ weco-0.2.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
+ weco-0.2.4.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
+ weco-0.2.4.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
+ weco-0.2.4.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- weco/__init__.py,sha256=bR_VMLdj9CKuS7r20P1w045efBJ-Jndx8NFtQVc3_78,124
2
- weco/api.py,sha256=JHAm60sO51Y2tzLnyAAFv9OLm75o_RNWeoK-gYF4VHE,3342
3
- weco/cli.py,sha256=Raq6X5ZSalPe0BV18UA_arC_jrNkQkJ4gDqWNTMlfsI,16242
4
- weco/panels.py,sha256=Y0K6Nx4uCBREdVL1c3ee7a3ZNjyhXJFThZBCToG3xO0,11970
5
- weco/utils.py,sha256=g1Lchd3_L-eGRNkqr2IyRZ5FJfZTrFf9aTmmpMtdhko,3761
6
- weco-0.2.3.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
- weco-0.2.3.dist-info/METADATA,sha256=GXFnAZjqNTXZGq8NC_zWvuq243ZZSsW0zYGrVEP8K0Y,5229
8
- weco-0.2.3.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
- weco-0.2.3.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
- weco-0.2.3.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
- weco-0.2.3.dist-info/RECORD,,
File without changes