Skip to content

Commit

Permalink
Merge pull request #16197 from mvdbeek/dev
Browse files Browse the repository at this point in the history
Merge 23.0 into dev
  • Loading branch information
mvdbeek committed Jun 6, 2023
2 parents 6829d5b + 368dfb3 commit 9758ef4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/model/store/__init__.py
Expand Up @@ -2450,7 +2450,7 @@ def _init_crate(self) -> ROCrate:
"encodingFormat": encoding_format,
}
ro_crate.add_file(
file_name,
os.path.join(self.export_directory, file_name),
dest_path=file_name,
properties=properties,
)
Expand Down
14 changes: 12 additions & 2 deletions lib/galaxy/model/store/ro_crate_utils.py
Expand Up @@ -6,6 +6,8 @@
Optional,
)

from packaging.version import parse
from rocrate import __version__ as rocrate_version
from rocrate.model.computationalworkflow import (
ComputationalWorkflow,
WorkflowDescription,
Expand Down Expand Up @@ -102,13 +104,21 @@ def _add_file(self, dataset: HistoryDatasetAssociation, properties: Dict[Any, An
if dataset.dataset.id in self.model_store.dataset_id_to_path:
filename, _ = self.model_store.dataset_id_to_path[dataset.dataset.id]
if not filename:
# dataset was not serialized
filename = f"datasets/dataset_{dataset.dataset.uuid}"
if parse(rocrate_version) >= parse("0.8.0"):
source = None
else:
# Drop in 23.1
source = filename
else:
source = os.path.join(self.model_store.export_directory, filename)
name = dataset.name
encoding_format = dataset.datatype.get_mime()
properties["name"] = name
properties["encodingFormat"] = encoding_format
file_entity = crate.add_file(
filename,
source,
dest_path=filename,
properties=properties,
)
Expand Down Expand Up @@ -272,7 +282,7 @@ def _add_attrs_files(self, crate: ROCrate):
"encodingFormat": "application/json",
}
crate.add_file(
attrs,
attrs_path,
dest_path=attrs,
properties=properties,
)
Expand Down
37 changes: 33 additions & 4 deletions scripts/release.py
Expand Up @@ -141,8 +141,17 @@ def read_package(package_path: pathlib.Path) -> Package:
return package


def _get_docutils_parser_settings():
try:
return frontend.get_default_settings(Parser)
except AttributeError:
# docutils < 0.18. Remove fallback in 23.1
components = (Parser,)
return frontend.OptionParser(components=components).get_default_values()


def parse_changelog(package: Package) -> List[ChangelogItem]:
settings = frontend.get_default_settings(Parser)
settings = _get_docutils_parser_settings()
document = utils.new_document(str(package.history_rst), settings)
Parser().parse(package.history_rst.read_text(), document)
changelog_items: List[ChangelogItem] = []
Expand Down Expand Up @@ -440,6 +449,23 @@ def is_merge_required(base_branch: str, new_branch: str, galaxy_root: pathlib.Pa
return True


def ensure_branches_up_to_date(branches: List[str], base_branch: str, upstream: str, galaxy_root: pathlib.Path):
for branch in branches:
subprocess.run(["git", "checkout", branch], cwd=galaxy_root).check_returncode()
# Check that the head commit matches the commit for the same branch at the specified remote repo url
result = subprocess.run(["git", "ls-remote", upstream, f"refs/heads/{branch}"], capture_output=True, text=True)
result.check_returncode()
remote_commit_hash = result.stdout.split("\t")[0]
result = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True)
result.check_returncode()
local_commit_hash = result.stdout.strip()
if remote_commit_hash != local_commit_hash:
raise Exception(
f"Local tip of branch {branch} is {local_commit_hash}, remote tip of branch is {remote_commit_hash}. Make sure that your local branches are up to date and track f{upstream}."
)
subprocess.run(["git", "checkout", base_branch], cwd=galaxy_root).check_returncode()


def push_references(references: List[str], upstream: str = "https://github.com/galaxyproject/galaxy.git"):
for reference in references:
subprocess.run(["git", "push", upstream, reference]).check_returncode()
Expand Down Expand Up @@ -525,8 +551,11 @@ def create_point_release(
click.confirm("Does this look correct?", abort=True)
base_branch = current_branch = get_current_branch(galaxy_root)
newer_branches = get_branches(galaxy_root, new_version, base_branch)
all_branches = newer_branches + [base_branch]
click.echo("Making sure that all branches are up to date")
ensure_branches_up_to_date(all_branches, base_branch, upstream, galaxy_root)

click.echo("Making sure that merging forward will result in clean merges")
merge_required = False
for new_branch in newer_branches:
merge_required = is_merge_required(base_branch=current_branch, new_branch=new_branch, galaxy_root=galaxy_root)
if merge_required:
Expand All @@ -537,7 +566,7 @@ def create_point_release(
if click.confirm("Continue anyway ?", abort=True):
current_branch = new_branch
break
subprocess.run(["git", "checkout", base_branch], cwd=galaxy_root)
subprocess.run(["git", "checkout", base_branch], cwd=galaxy_root).check_returncode()
modified_paths = [set_root_version(galaxy_root, new_version)]
# read packages and find prs that affect a package
packages: List[Package] = []
Expand Down Expand Up @@ -600,7 +629,7 @@ def create_point_release(
click.echo(f"Merging {base_branch} into {new_branch}")
merge_and_resolve_branches(galaxy_root, current_branch, new_branch, packages)
current_branch = new_branch
references = [release_tag, base_branch] + newer_branches
references = [release_tag] + all_branches
if no_confirm or click.confirm(f"Push {','.join(references)} to upstream '{upstream}' ?", abort=True):
push_references(references=references, upstream=upstream)

Expand Down
1 change: 0 additions & 1 deletion test/unit/data/model/test_model_store.py
Expand Up @@ -347,7 +347,6 @@ def validate_has_pl_galaxy(ro_crate: ROCrate):
assert programming_language.id == "https://w3id.org/workflowhub/workflow-ro-crate#galaxy"
assert programming_language.name == "Galaxy"
assert programming_language.url == "https://galaxyproject.org/"
assert programming_language.version


def validate_organize_action(ro_crate: ROCrate):
Expand Down

0 comments on commit 9758ef4

Please sign in to comment.