Source code for bridge.pipelines.bt2gh_for_pr_issues.main
"""
Implements the bio.tools→GitHub PR pipeline:
given a checkout path and a BiotoolsToolModel,
produce file changes to propose in a pull request.
"""
import logging
from bridge.core import BiotoolsToolModel, GitHubRepoModel
from bridge.pipelines.protocols import PipelineArgs
from .map import MapBioTools2GitHub, MapDestination
logger = logging.getLogger(__name__)
[docs]
async def run(args: BiotoolsToGitHubForPRPipelineArgs) -> tuple[dict, dict]:
"""
Run the pipeline to generate repository file changes based on bio.tools metadata.
Parameters
----------
args: BiotoolsToGitHubForPRPipelineArgs
The pipeline arguments containing a path to the cloned GitHub repository and metadata model.
Returns
-------
tuple[dict, dict]
A dictionary mapping file paths to their new content, and
a dictionary mapping issue titles to their bodies.
"""
logger.info(f"Running bio.tools → GitHub PR pipeline for {args.metadata_model.name}")
existing_repo_model = args.existing_repo_model
biotools_model = args.metadata_model
# Generate file changes based on biotools_model
mapper = MapBioTools2GitHub(
repo=existing_repo_model,
metadata=biotools_model,
repo_path=args.repo_path,
)
dest = MapDestination()
issues = {}
for issue in dest.issue:
map_item = mapper.map[issue]
new_issue = await map_item.run()
if new_issue:
issues |= new_issue
file_changes = {}
for pr in dest.pr:
map_item = mapper.map[pr]
new_file_change = await map_item.run()
if new_file_change:
file_changes |= new_file_change
# logger.info(f"Generated file changes for repo at {repo_path}: {file_changes.keys()}")
return file_changes, issues