Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto wandb tag with benchmark.py #308

Merged
merged 6 commits into from
Nov 2, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor
  • Loading branch information
vwxyzjn committed Oct 31, 2022
commit 5fdca5f71f356bdab1fdd4b2f8ca9db119579edc
39 changes: 25 additions & 14 deletions cleanrl_utils/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,31 @@ def run_experiment(command: str):


def autotag() -> str:
git_tag = subprocess.check_output(["git", "describe", "--tags"]).decode("ascii").strip()
wandb_tag = ""
print("autotag feature is enabled")
try:
git_tag = subprocess.check_output(["git", "describe", "--tags"]).decode("ascii").strip()
wandb_tag = f"{git_tag}"
print(f"identified git tag: {git_tag}")
except subprocess.CalledProcessError:
return wandb_tag

git_commit = subprocess.check_output(["git", "rev-parse", "--verify", "HEAD"]).decode("ascii").strip()
try:
# try finding the pull request number on github
prs = requests.get(f"https://api.github.com/repos/vwxyzjn/cleanrl/commits/{git_commit}/pulls")
if prs.status_code == 200:
prs = prs.json()
if len(prs) > 0:
pr = prs[0]
pr_number = pr["number"]
pr["title"]
pr["html_url"]
wandb_tag += f",pr-{pr_number}"
print(f"identified github pull request: {pr_number}")
except Exception as e:
print(e)

# try finding the pull request number on github
prs = requests.get(f"https://api.github.com/repos/vwxyzjn/cleanrl/commits/{git_commit}/pulls")
if prs.status_code == 200:
prs = prs.json()
if len(prs) > 0:
pr = prs[0]
pr_number = pr["number"]
pr["title"]
pr["html_url"]
wandb_tag = f"{git_tag},pr{pr_number}"
else:
wandb_tag = f"{git_tag}"
return wandb_tag


Expand All @@ -61,7 +71,8 @@ def autotag() -> str:
"WANDB_TAGS is already set. Please unset it before running this script or run the script with --auto-tag False"
)
wandb_tag = autotag()
os.environ["WANDB_TAGS"] = wandb_tag
if len(wandb_tag) > 0:
os.environ["WANDB_TAGS"] = wandb_tag

commands = []
for seed in range(1, args.num_seeds + 1):
Expand Down