Skip to content

Commit

Permalink
fix(cli): fixed import -o flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedantsahai18 committed Feb 6, 2025
1 parent 2a9ff55 commit f3d4511
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions cli/src/julep_cli/importt.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def importt(
confirm = typer.confirm(f"Are you sure you want to import agent '{id}' to '{output}'?")
if not confirm:
console.print(Text("Operation cancelled", style="bold red"), highlight=True)
raise typer.Exit
raise typer.Exit(1)

try:
client = get_julep_client()
Expand Down Expand Up @@ -254,9 +254,23 @@ def importt(

console.print(table, highlight=True)

# Ensure output is an absolute path relative to source.
# If the user provided a relative output value, treat it as subpath of the source.
if not output.is_absolute():
output = source / output

agent_name = remote_agent.name.lower().replace(" ", "_")

agent_yaml_path: Path = output / f"{agent_name}.yaml"
# If the provided output has a .yaml suffix, treat it as the target file;
# otherwise, generate a file name based on the agent name.
if output.suffix == ".yaml":
agent_yaml_path: Path = output
else:
agent_yaml_path: Path = output / f"{agent_name}.yaml"

# Ensure that the parent directory exists
agent_yaml_path.parent.mkdir(parents=True, exist_ok=True)

typer.echo(f"Adding agent '{remote_agent.name}' to '{agent_yaml_path}'...")
update_yaml_for_existing_entity(
agent_yaml_path, remote_agent.model_dump(exclude={"id", "created_at", "updated_at"})
Expand Down
2 changes: 1 addition & 1 deletion cli/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion documentation/guides/julepcli/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ Following are the available commands.
The `julep run` command is used to execute a task.

<ParamField path="--task" type="string" required>
ID or name of the task to execute
ID of the task to execute
</ParamField>

<ParamField path="--input" type="json">
Expand Down

0 comments on commit f3d4511

Please sign in to comment.