From b65bc159417476aaa52b19235325371ec93196eb Mon Sep 17 00:00:00 2001 From: Teo Date: Sat, 18 Jan 2025 21:20:22 +0200 Subject: [PATCH 1/3] chore: switch to hatch-vcs based versioning Signed-off-by: Teo --- pyproject.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d3f09da22..c646e1c10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" }, @@ -187,3 +187,6 @@ exclude = [ [tool.hatch.metadata] allow-direct-references = true +[tool.hatch.version] +source = "vcs" + From f15e8617764a8bd1bcf172dc5fd56cc7ca89a8ff Mon Sep 17 00:00:00 2001 From: Teo Date: Sat, 18 Jan 2025 21:23:08 +0200 Subject: [PATCH 2/3] Enable `agentops` cli command pointing to `agentops.cli` Signed-off-by: Teo --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c646e1c10..f5336bf97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -189,4 +193,3 @@ allow-direct-references = true [tool.hatch.version] source = "vcs" - From 43d9917ce5620f07fde9d74191e8d8ae155f89f6 Mon Sep 17 00:00:00 2001 From: Teo Date: Sat, 18 Jan 2025 21:23:30 +0200 Subject: [PATCH 3/3] cli: add version command and improve general parser Signed-off-by: Teo --- agentops/cli.py | 53 +++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/agentops/cli.py b/agentops/cli.py index 29a81123e..d5a295aa3 100644 --- a/agentops/cli.py +++ b/agentops/cli.py @@ -1,35 +1,40 @@ import argparse +import importlib.metadata + 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?") + + 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") + + # Version command + version_parser = subparsers.add_parser("version", help="Show AgentOps version") + + # 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") 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)) if args.off: set_time_travel_active_state(False) + + +if __name__ == "__main__": + main()