Skip to content

Commit

Permalink
Merge pull request #1459 from microsoft/autogenbench_i1458
Browse files Browse the repository at this point in the history
Prints the version of AutoGenBench from the command line, closing i1458
  • Loading branch information
afourney authored Jan 30, 2024
2 parents 3608079 + faaf883 commit 99783d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 11 additions & 0 deletions samples/tools/autogenbench/autogenbench/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from .version import __version__
from .run_cmd import run_cli
from .clone_cmd import clone_cli
from .tabulate_cmd import tabulate_cli
Expand All @@ -9,6 +10,7 @@ def main(args=None):
args = sys.argv[:] # Shallow copy

invocation_cmd = "autogenbench"
version_string = f"AutoGenBench version {__version__}"

commands = [
{
Expand All @@ -26,6 +28,11 @@ def main(args=None):
"description": "tabulate the results of a previous run",
"function": tabulate_cli,
},
{
"command": "--version",
"description": f"print the version of {invocation_cmd}",
"function": lambda _args: print(f"{version_string}"),
},
{"command": "--help", "description": "print this message", "function": None},
]

Expand All @@ -40,6 +47,8 @@ def main(args=None):
commands_details += f" {padded_cmd}: {c['description']}\n"

usage_text = f"""
{version_string}
usage: {invocation_cmd} COMMAND ARGS
Where, COMMAND is one of: {commands_list}
Expand All @@ -49,6 +58,8 @@ def main(args=None):
""".strip()

help_text = f"""
{version_string}
usage: {invocation_cmd} COMMAND ARGS
{invocation_cmd} is a tool for running and managing AutoGen benchmark scenarios. A typically session might resemble:
Expand Down
4 changes: 4 additions & 0 deletions samples/tools/autogenbench/autogenbench/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import random
from autogen import config_list_from_json
from autogen.oai.openai_utils import filter_config
from .version import __version__

# Figure out where everything is
SCRIPT_PATH = os.path.realpath(__file__)
Expand Down Expand Up @@ -286,6 +287,7 @@ def run_scenario_natively(work_dir, env, timeout=TASK_TIMEOUT):
f"""#
echo RUN.SH STARTING !#!#
export AUTOGEN_TESTBED_SETTING="Native"
echo "autogenbench version: {__version__}" > timestamp.txt
# Run the global init script if it exists
if [ -f global_init.sh ] ; then
Expand Down Expand Up @@ -387,7 +389,9 @@ def run_scenario_in_docker(work_dir, env, timeout=TASK_TIMEOUT, docker_image=Non
f"""#
echo RUN.SH STARTING !#!#
export AUTOGEN_TESTBED_SETTING="Docker"
umask 000
echo "autogenbench version: {__version__}" > timestamp.txt
# Run the global init script if it exists
if [ -f global_init.sh ] ; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def init():
"""

# Print some information about the run
with open("timestamp.txt", "wt") as f:
f.write("Timestamp: " + datetime.now().isoformat() + "\n")
with open("timestamp.txt", "at") as f:
f.write("pyautogen version: " + str(autogen.__version__) + "\n")
f.write("Timestamp: " + datetime.now().isoformat() + "\n")

# Start logging
if AUTOGEN_VERSION < packaging.version.parse("0.2.0b1"):
Expand Down

0 comments on commit 99783d0

Please sign in to comment.