Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions agentops/cli.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
import argparse
import importlib.metadata

Check warning on line 2 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L2

Added line #L2 was not covered by tests

from .time_travel import fetch_time_travel_id, set_time_travel_active_state


def version_command():
try:
version = importlib.metadata.version("agentops")
print(f"AgentOps version: {version}")
except importlib.metadata.PackageNotFoundError:
print("AgentOps package not found. Are you in development mode?")

Check warning on line 12 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L7-L12

Added lines #L7 - L12 were not covered by tests


def main():
parser = argparse.ArgumentParser(description="AgentOps CLI")
subparsers = parser.add_subparsers(dest="command")

timetravel_parser = subparsers.add_parser("timetravel", help="Time Travel Debugging commands", aliases=["tt"])
timetravel_parser.add_argument(
"branch_name",
type=str,
nargs="?",
help="Given a branch name, fetches the cache file for Time Travel Debugging. Turns on feature by default",
)
timetravel_parser.add_argument(
"--on",
action="store_true",
help="Turns on Time Travel Debugging",
)
timetravel_parser.add_argument(
"--off",
action="store_true",
help="Turns off Time Travel Debugging",
)
subparsers = parser.add_subparsers(dest="command", help="Available commands")

Check warning on line 17 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L17

Added line #L17 was not covered by tests

# Version command
version_parser = subparsers.add_parser("version", help="Show AgentOps version")

Check warning on line 20 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L20

Added line #L20 was not covered by tests

# Time travel command
time_travel_parser = subparsers.add_parser("time-travel", help="Time travel related commands")
time_travel_parser.add_argument("--id", help="Get time travel ID", action="store_true")
time_travel_parser.add_argument("--off", help="Turn off time travel", action="store_true")

Check warning on line 25 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L23-L25

Added lines #L23 - L25 were not covered by tests

args = parser.parse_args()

if args.command in ["timetravel", "tt"]:
if args.branch_name:
fetch_time_travel_id(args.branch_name)
if args.on:
set_time_travel_active_state(True)
if args.command == "version":
version_command()
elif args.command == "time-travel":
if args.id:
ttd_id = None # This would typically come from somewhere
print(fetch_time_travel_id(ttd_id))

Check warning on line 34 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L29-L34

Added lines #L29 - L34 were not covered by tests
if args.off:
set_time_travel_active_state(False)


if __name__ == "__main__":
main()

Check warning on line 40 in agentops/cli.py

View check run for this annotation

Codecov / codecov/patch

agentops/cli.py#L39-L40

Added lines #L39 - L40 were not covered by tests
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "agentops"
version = "0.3.24"
dynamic = ["version"]
authors = [
{ name="Alex Reibman", email="areibman@gmail.com" },
{ name="Shawn Qiu", email="siyangqiu@gmail.com" },
Expand Down Expand Up @@ -39,6 +39,10 @@ dependencies = [
"opentelemetry-exporter-otlp-proto-http>=1.27.0; python_version>='3.10'",
]

[project.scripts]
agentops = "agentops.cli:main"


[dependency-groups]
test = [
"openai>=1.0.0",
Expand Down Expand Up @@ -187,3 +191,5 @@ exclude = [
[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.version]
source = "vcs"
Loading