fastworkflow 2.8.13__py3-none-any.whl → 2.8.14__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.
fastworkflow/cli.py CHANGED
@@ -129,15 +129,15 @@ def train_example(args):
129
129
  """Train an existing example workflow."""
130
130
  # Check if example exists in the local examples directory
131
131
  local_examples_dir = Path("./examples")
132
- example_path = local_examples_dir / args.name
132
+ workflow_path = local_examples_dir / args.name
133
133
 
134
- if not example_path.is_dir():
134
+ if not workflow_path.is_dir():
135
135
  print(f"Error: Example '{args.name}' not found in '{local_examples_dir}'.", file=sys.stderr)
136
136
  print(f"Use 'fastworkflow examples fetch {args.name}' to fetch the example first.")
137
137
  print("Or use 'fastworkflow examples list' to see available examples.")
138
138
  sys.exit(1)
139
139
 
140
- print(f"Training example in '{example_path}'...")
140
+ print(f"Training example in '{workflow_path}'...")
141
141
 
142
142
  # Get the appropriate env files for this example workflow
143
143
  env_file_path, passwords_file_path = find_default_env_files(local_examples_dir)
@@ -158,41 +158,29 @@ def train_example(args):
158
158
  print(f" {local_examples_dir}/fastworkflow.passwords.env")
159
159
  sys.exit(1)
160
160
 
161
- # The `train` script needs the path to the workflow, and the env files
162
- cmd = [
163
- sys.executable,
164
- "-m", "fastworkflow.train",
165
- str(example_path),
166
- str(env_file),
167
- str(passwords_file)
168
- ]
161
+ # Create args object for train_main
162
+ train_args = argparse.Namespace(
163
+ workflow_folderpath=str(workflow_path),
164
+ env_file_path=str(env_file),
165
+ passwords_file_path=str(passwords_file)
166
+ )
169
167
 
170
168
  try:
171
- # We run the command from the current working directory
172
- process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, encoding='utf-8')
173
-
174
- # Stream the output
175
- if process.stdout:
176
- for line in iter(process.stdout.readline, ''):
177
- print(line, end='')
178
-
179
- process.wait()
180
-
181
- if process.returncode == 0:
169
+ # Call train_main directly instead of using subprocess
170
+ result = train_main(train_args)
171
+
172
+ if result is None or result == 0:
182
173
  print(f"\n✅ Successfully trained example '{args.name}'.")
183
- print(f"You can now run it with:\npython -m fastworkflow.run {example_path}")
174
+ print(f"You can now run it with:\npython -m fastworkflow.run {workflow_path}")
184
175
  else:
185
- print(f"\n❌ Training failed with exit code {process.returncode}.", file=sys.stderr)
176
+ print(f"\n❌ Training failed.", file=sys.stderr)
186
177
  sys.exit(1)
187
178
 
188
- except FileNotFoundError:
189
- print("Error: 'python' executable not found. Make sure your environment is set up correctly.", file=sys.stderr)
190
- sys.exit(1)
191
179
  except Exception as e:
192
180
  print(f"An unexpected error occurred during training: {e}", file=sys.stderr)
193
181
  sys.exit(1)
194
182
 
195
- def find_default_env_files(workflow_path=None):
183
+ def find_default_env_files(workflow_path):
196
184
  """Find the appropriate default env files based on context.
197
185
 
198
186
  If the workflow path is within the examples directory, use the local examples env files.
@@ -204,34 +192,8 @@ def find_default_env_files(workflow_path=None):
204
192
  Returns:
205
193
  tuple: (env_file_path, passwords_file_path)
206
194
  """
207
- # Default to local env files for user workflows
208
- default_env = ".env"
209
- default_passwords = "passwords.env"
210
-
211
- # If workflow_path is provided and seems to be an example workflow
212
- if workflow_path:
213
- workflow_path = Path(workflow_path)
214
- examples_dir, is_package = find_examples_dir()
215
-
216
- if examples_dir and (
217
- str(workflow_path).startswith(str(examples_dir)) or
218
- "/examples/" in str(workflow_path) or
219
- "\\examples\\" in str(workflow_path)
220
- ):
221
- # For example workflows, check for the env files in the local examples directory
222
- local_examples_dir = Path("./examples")
223
- local_env = local_examples_dir / "fastworkflow.env"
224
- local_passwords = local_examples_dir / "fastworkflow.passwords.env"
225
-
226
- if local_env.exists() and local_passwords.exists():
227
- return str(local_env), str(local_passwords)
228
-
229
- # If not found locally, return the expected paths anyway
230
- # (the calling function will handle the error appropriately)
231
- return str(local_env), str(local_passwords)
232
-
233
- # For user workflows, use local env files
234
- return default_env, default_passwords
195
+ workflow_path = Path(workflow_path)
196
+ return workflow_path / "fastworkflow.env", workflow_path / "fastworkflow.passwords.env"
235
197
 
236
198
  def add_build_parser(subparsers):
237
199
  """Add subparser for the 'build' command."""
@@ -365,9 +327,9 @@ def run_example(args):
365
327
  """Run an existing example workflow."""
366
328
  # Check if example exists in the local examples directory
367
329
  local_examples_dir = Path("./examples")
368
- example_path = local_examples_dir / args.name
330
+ workflow_path = local_examples_dir / args.name
369
331
 
370
- if not example_path.is_dir():
332
+ if not workflow_path.is_dir():
371
333
  print(f"Error: Example '{args.name}' not found in '{local_examples_dir}'.", file=sys.stderr)
372
334
  print(f"Use 'fastworkflow examples fetch {args.name}' to fetch the example first.")
373
335
  print("Or use 'fastworkflow examples list' to see available examples.")
@@ -397,7 +359,7 @@ def run_example(args):
397
359
  sys.exit(1)
398
360
 
399
361
  # Check if the example has been trained
400
- command_info_dir = example_path / "___command_info"
362
+ command_info_dir = workflow_path / "___command_info"
401
363
  if not command_info_dir.exists() or not any(command_info_dir.iterdir()):
402
364
  print(f"Warning: Example '{args.name}' does not appear to be trained yet.", file=sys.stderr)
403
365
  print(f"Please train the example first with:")
@@ -412,7 +374,7 @@ def run_example(args):
412
374
  cmd = [
413
375
  sys.executable,
414
376
  "-m", "fastworkflow.run",
415
- str(example_path),
377
+ str(workflow_path),
416
378
  str(env_file),
417
379
  str(passwords_file)
418
380
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastworkflow
3
- Version: 2.8.13
3
+ Version: 2.8.14
4
4
  Summary: A framework for rapidly building large-scale, deterministic, interactive workflows with a fault-tolerant, conversational UX
5
5
  License: Apache-2.0
6
6
  Keywords: fastworkflow,ai,workflow,llm,openai
@@ -31,7 +31,7 @@ fastworkflow/build/pydantic_model_generator.py,sha256=272j_O82sIEtUxnZH6rwM5dbEu
31
31
  fastworkflow/build/utterance_generator.py,sha256=OuxIZAl70ZW5l5jIlQxsE9gfzyCwXTtSdhK67Zwyk-I,1668
32
32
  fastworkflow/cache_matching.py,sha256=WoSQ7QuVGqOnecsIIdwb3A6gBpt0OJdSzx_a51nHoFA,6458
33
33
  fastworkflow/chat_session.py,sha256=lEpJmU_2a-4pB4QR7wACl8jHWZls1ROtQGgdVObY3BA,12308
34
- fastworkflow/cli.py,sha256=-JN62W1WX6JjSwBFObtAKcgUDvm_6YInG5ewkxir8nQ,23102
34
+ fastworkflow/cli.py,sha256=GmwV-uWOysBIxA17pPR4s357Qut7ge5R2nTteYnIkOc,21526
35
35
  fastworkflow/command_context_model.py,sha256=nWxLP3TR7WJr3yWCedqcdFOxo_kwae_mS3VRN2cOmK8,13437
36
36
  fastworkflow/command_directory.py,sha256=iUW8168fX6bTytPtYI1gcTHqORv0_qNZ7Nhhwr-ujqs,27163
37
37
  fastworkflow/command_executor.py,sha256=bKqOHBEVhCunE3B-zh6DNLERUiSmEiVJdfEoVVUq-zM,6412
@@ -146,8 +146,8 @@ fastworkflow/utils/pydantic_model_2_dspy_signature_class.py,sha256=w1pvl8rJq48ul
146
146
  fastworkflow/utils/python_utils.py,sha256=Lt6P8lBMbLuLZaP9gd_7Kl7UvSPLm-NKPN6cPUdn53w,8194
147
147
  fastworkflow/utils/signatures.py,sha256=4ksF-65Q-22ZR_SW8O_cv5RhKKk0ecmWgykoAGKxr-k,19957
148
148
  fastworkflow/workflow.py,sha256=zHsA67IMlHAhpgM2CN96G_KsU_eMVXJf7axZ2zBBdhU,16436
149
- fastworkflow-2.8.13.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
150
- fastworkflow-2.8.13.dist-info/METADATA,sha256=rn1eEY18U2uEwmHlmRp643tZ6YppuFfV-G670MnR2Kg,15387
151
- fastworkflow-2.8.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
152
- fastworkflow-2.8.13.dist-info/entry_points.txt,sha256=m8HqoPzCyaZLAx-V5X8MJgw3Lx3GiPDlxNEZ7K-Gb-U,54
153
- fastworkflow-2.8.13.dist-info/RECORD,,
149
+ fastworkflow-2.8.14.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
150
+ fastworkflow-2.8.14.dist-info/METADATA,sha256=T4cyt9gfiaVGLmgwfGxRzXM-jUn9EIuYXYpo8Y7Ss9Q,15387
151
+ fastworkflow-2.8.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
152
+ fastworkflow-2.8.14.dist-info/entry_points.txt,sha256=m8HqoPzCyaZLAx-V5X8MJgw3Lx3GiPDlxNEZ7K-Gb-U,54
153
+ fastworkflow-2.8.14.dist-info/RECORD,,