-
Notifications
You must be signed in to change notification settings - Fork 22
Implement same dependency/release update workflow as WarpX #474
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"version_pyamrex": "25.09", | ||
"version_amrex": "25.09", | ||
"version_pybind11": "3.0.0", | ||
"commit_amrex": "95822df1a393b39aeca5e590328e228513132159", | ||
"commit_pybind11": "v3.0.0" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# This file is part of pyAMReX. | ||
# | ||
# License: BSD-3-Clause-LBNL | ||
|
||
import argparse | ||
import copy | ||
import datetime | ||
import json | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
import requests | ||
|
||
|
||
def update(args): | ||
# list of repositories to update | ||
repo_dict = {} | ||
if args.all or args.amrex: | ||
repo_dict["amrex"] = {} | ||
repo_dict["amrex"]["commit"] = ( | ||
"https://api.github.com/repos/AMReX-Codes/amrex/commits/development" | ||
) | ||
repo_dict["amrex"]["tags"] = ( | ||
"https://api.github.com/repos/AMReX-Codes/amrex/tags" | ||
) | ||
if args.all or args.pybind11: | ||
repo_dict["pybind11"] = {} | ||
repo_dict["pybind11"]["commit"] = ( | ||
"https://api.github.com/repos/pybind/pybind11/commits/master" | ||
) | ||
repo_dict["pybind11"]["tags"] = ( | ||
"https://api.github.com/repos/pybind/pybind11/tags" | ||
) | ||
if args.all or args.pyamrex: | ||
repo_dict["pyamrex"] = {} | ||
repo_dict["pyamrex"]["commit"] = ( | ||
"https://api.github.com/repos/AMReX-Codes/pyamrex/commits/development" | ||
) | ||
repo_dict["pyamrex"]["tags"] = ( | ||
"https://api.github.com/repos/AMReX-Codes/pyamrex/tags" | ||
) | ||
|
||
# list of repositories labels for logging convenience | ||
repo_labels = { | ||
"amrex": "AMReX", | ||
"pybind11": "pybind11", | ||
"pyamrex": "pyAMReX", | ||
} | ||
|
||
# read from JSON file with dependencies data | ||
repo_dir = Path(__file__).parent.absolute() | ||
dependencies_file = os.path.join(repo_dir, "dependencies.json") | ||
try: | ||
with open(dependencies_file, "r") as file: | ||
dependencies_data = json.load(file) | ||
except Exception as e: | ||
print(f"An unexpected error occurred: {e}") | ||
sys.exit() | ||
|
||
# loop over repositories and update dependencies data | ||
for repo_name, repo_subdict in repo_dict.items(): | ||
print(f"\nUpdating {repo_labels[repo_name]}...") | ||
# set keys to access dependencies data | ||
commit_key = f"commit_{repo_name}" | ||
version_key = f"version_{repo_name}" | ||
# get new commit information | ||
commit_response = requests.get(repo_subdict["commit"]) | ||
commit_dict = commit_response.json() | ||
# set new commit | ||
repo_commit_sha = commit_dict["sha"] | ||
# get new version tag information | ||
tags_response = requests.get(repo_subdict["tags"]) | ||
tags_list = tags_response.json() | ||
# filter out old-format tags for specific repositories | ||
tags_list_filtered = copy.deepcopy(tags_list) | ||
if repo_name == "amrex": | ||
tags_list_filtered = [ | ||
tag_dict | ||
for tag_dict in tags_list | ||
if (tag_dict["name"] != "boxlib" and tag_dict["name"] != "v2024") | ||
] | ||
# set new version tag | ||
if repo_name == "pyamrex": | ||
# current date version for the pyAMReX release update | ||
repo_version_tag = datetime.date.today().strftime("%y.%m") | ||
else: | ||
# latest available tag (index 0) for all other dependencies | ||
repo_version_tag = tags_list_filtered[0]["name"] | ||
# use version tag instead of commit sha for a release update | ||
new_commit_sha = repo_version_tag if args.release else repo_commit_sha | ||
# update commit | ||
if repo_name != "pyamrex": | ||
print(f"- old commit: {dependencies_data[commit_key]}") | ||
print(f"- new commit: {new_commit_sha}") | ||
if dependencies_data[commit_key] == new_commit_sha: | ||
print("Skipping commit update...") | ||
else: | ||
print("Updating commit...") | ||
dependencies_data[f"commit_{repo_name}"] = new_commit_sha | ||
# update version | ||
print(f"- old version: {dependencies_data[version_key]}") | ||
print(f"- new version: {repo_version_tag}") | ||
if dependencies_data[version_key] == repo_version_tag: | ||
print("Skipping version update...") | ||
else: | ||
print("Updating version...") | ||
dependencies_data[f"version_{repo_name}"] = repo_version_tag | ||
|
||
# write to JSON file with dependencies data | ||
with open(dependencies_file, "w") as file: | ||
json.dump(dependencies_data, file, indent=4) | ||
|
||
|
||
if __name__ == "__main__": | ||
# define parser | ||
parser = argparse.ArgumentParser() | ||
|
||
# add arguments: AMReX option | ||
parser.add_argument( | ||
"--amrex", | ||
help="Update AMReX only", | ||
action="store_true", | ||
dest="amrex", | ||
) | ||
|
||
# add arguments: pybind11 option | ||
parser.add_argument( | ||
"--pybind11", | ||
help="Update pybind11 only", | ||
action="store_true", | ||
dest="pybind11", | ||
) | ||
|
||
# add arguments: pyAMReX option | ||
parser.add_argument( | ||
"--pyamrex", | ||
help="Update pyAMReX only", | ||
action="store_true", | ||
dest="pyamrex", | ||
) | ||
|
||
# add arguments: release option | ||
parser.add_argument( | ||
"--release", | ||
help="New release", | ||
action="store_true", | ||
dest="release", | ||
) | ||
|
||
# parse arguments | ||
args = parser.parse_args() | ||
|
||
# set args.all automatically | ||
args.all = False if (args.amrex or args.pybind11 or args.pyamrex) else True | ||
|
||
# update | ||
update(args) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Down the road it would be nice if we found a way to make this a BLAST-level module, since a lot of code is shared with the WarpX script.