Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into EISW-121295-indic…
Browse files Browse the repository at this point in the history
…es-as-ids-poc
  • Loading branch information
razvanapetroaie committed Jul 29, 2024
2 parents e5960a1 + 843c3c3 commit 76dbce1
Show file tree
Hide file tree
Showing 180 changed files with 4,343 additions and 956 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

# QA Tests:
/tests/ @openvinotoolkit/openvino-tests-maintainers
/tests/layer_tests/ @openvinotoolkit/openvino-tests-maintainers @openvinotoolkit/openvino-mo-maintainers
/tests/layer_tests/ @openvinotoolkit/openvino-tests-maintainers @openvinotoolkit/openvino-ovc-maintainers
/tests/layer_tests/pytorch_tests/ @openvinotoolkit/openvino-pytorch-frontend-maintainers
/tests/layer_tests/tensorflow_tests @openvinotoolkit/openvino-tf-frontend-maintainers
/tests/layer_tests/jax_tests @openvinotoolkit/openvino-tf-frontend-maintainers @openvinotoolkit/openvino-jax-frontend-maintainers
Expand All @@ -110,15 +110,15 @@
/tools/legacy/ @openvinotoolkit/openvino-samples-maintainers
/tools/openvino_dev/ @openvinotoolkit/openvino-tools-maintainers @openvinotoolkit/openvino-ie-python-api-maintainers
/tools/mo/ @openvinotoolkit/openvino-mo-maintainers
/tools/ovc/ @openvinotoolkit/openvino-mo-maintainers
/tools/ovc/ @openvinotoolkit/openvino-ovc-maintainers
/thirdparty/open_model_zoo/ @openvinotoolkit/omz-maintainers

# Documentation
/docs/ @openvinotoolkit/openvino-docs-maintainers
/docs/CMakeLists.txt @openvinotoolkit/openvino-ie-maintainers
/**/*.md @openvinotoolkit/openvino-docs-maintainers
/**/*.svg @openvinotoolkit/openvino-docs-maintainers
/docs/MO_DG/ @openvinotoolkit/openvino-docs-maintainers @openvinotoolkit/openvino-mo-maintainers
/docs/MO_DG/ @openvinotoolkit/openvino-docs-maintainers @openvinotoolkit/openvino-ovc-maintainers
/docs/OV_Runtime_UG/ @openvinotoolkit/openvino-docs-maintainers @openvinotoolkit/openvino-ie-maintainers
/docs/IE_PLUGIN_DG/ @openvinotoolkit/openvino-docs-maintainers @openvinotoolkit/openvino-ie-maintainers
/docs/Extensibility_UG/ @openvinotoolkit/openvino-docs-maintainers @openvinotoolkit/openvino-ie-maintainers
Expand Down
44 changes: 44 additions & 0 deletions .github/actions/create_manifest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'Create manifest'
description: 'Creates manifest containing versions of the product and the corresponding repositories'
inputs:
repos:
description: "Multi-line list of repositories to include to manifest"
required: true
product_type:
description: "Unique string to reflect product configuration"
required: true
save_to:
description: "Path to save manifest to"
required: true
action_path:
description: "Action path, if not set - taken from github context"
required: false
target_arch:
description: "Target architecture"
required: true
build_type:
description: "Build type: release | debug | release_with_debug"
required: true


runs:
using: "composite"
steps:
- name: Install Python dependencies
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
run: >-
pip install -r ${{ env.ACTION_PATH }}/requirements.txt
env:
ACTION_PATH: ${{ runner.os == 'Windows' && '$env:GITHUB_ACTION_PATH' || '$GITHUB_ACTION_PATH' }}

- name: 'Create manifest'
id: create_manifest
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
run: >-
python ${{ env.ACTION_PATH }}/create_manifest.py
--target_arch "${{ inputs.target_arch }}" --build_type "${{ inputs.build_type }}"
--save_to "${{ inputs.save_to }}" --product_type "${{ inputs.product_type }}" -r "${{ inputs.repos }}"
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
ACTION_PATH: ${{ runner.os == 'Windows' && '$env:GITHUB_ACTION_PATH' || '$GITHUB_ACTION_PATH' }}
128 changes: 128 additions & 0 deletions .github/actions/create_manifest/create_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
from __future__ import annotations

import argparse
import logging
import os
from datetime import timezone
from pathlib import Path
import re
import git

from manifest_manager import Manifest, Repository, Component


def parse_args():
parser = argparse.ArgumentParser(description='Creates manifest with product and repositories version')
parser.add_argument('-e', '--event_name', help='Name of GitHub event', required=False)
parser.add_argument('-r', '--repos', type=str, help='Paths to repositories to lon in manifest',
required=True)
parser.add_argument('--product_type', help='Unique string to reflect product configuration', required=True)
parser.add_argument('--target_arch', help='Target architecture', required=True)
parser.add_argument('--build_type', help='Build type: release | debug | release_with_debug', required=True)
parser.add_argument('--save_to', help='Path to save manifest to', required=True)
args = parser.parse_args()
return args


def init_logger():
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-15s %(levelname)-8s %(message)s',
datefmt='%m-%d-%Y %H:%M:%S')


def set_github_output(name: str, value: str, github_output_var_name: str = 'GITHUB_OUTPUT'):
"""Sets output variable for a GitHub Action"""
logger = logging.getLogger(__name__)
# In an environment variable "GITHUB_OUTPUT" GHA stores path to a file to write outputs to
with open(os.environ.get(github_output_var_name), 'a+') as file:
logger.info(f"Add {name}={value} to {github_output_var_name}")
print(f'{name}={value}', file=file)


def get_repo_data(repo_dir: str | Path) -> dict:
repo = git.Repo(str(repo_dir))
repo_url = next(repo.remote().urls)
repo_name_match = re.search(r'github\.com/[^/]+/([^/]+)', repo_url)
repo_name = repo_name_match.group(1) if repo_name_match else None

trigger_repo_url = f"{os.getenv('GITHUB_SERVER_URL')}/{os.getenv('GITHUB_REPOSITORY')}"
is_trigger_repo = repo_url == trigger_repo_url

branch = os.getenv('GITHUB_REF') if is_trigger_repo else repo.references[0].name
target_branch = os.getenv('GITHUB_BASE_REF') if is_trigger_repo else None
revision = os.getenv('PR_HEAD_SHA') or os.getenv('GITHUB_SHA') if is_trigger_repo else repo.head.commit.hexsha
target_revision = os.getenv('BASE_SHA') if is_trigger_repo else None
# Commit time of a merge commit (in case of PR merged to target)
# TODO: Save commit time of a head commit in PR as well?
commit_time = repo.head.commit.committed_datetime.astimezone(timezone.utc)
merge_target = branch.endswith('/merge')
return {
'name': repo_name,
'url': repo_url,
'branch': branch.replace('refs/heads/', ''), # To align with internal manifest
'target_branch': target_branch,
'revision': revision,
'target_revision': target_revision,
'commit_time': commit_time,
'merge_target': merge_target,
'trigger': is_trigger_repo,
}


def parse_ov_version(header_file: str | Path) -> str:
header_code = Path(header_file).read_text()
major, minor, patch = (re.search(rf"#define OPENVINO_VERSION_{name} (\d+)", header_code).group(1)
for name in ["MAJOR", "MINOR", "PATCH"])
return f"{major}.{minor}.{patch}"


def generate_manifest(repos: list, product_type: str, event_type: str, build_type: str, target_arch: str) -> Manifest:
manifest = Manifest()
component_name = 'dldt' # historical, keep for internal compatibility
repositories = []
ov_version = None
trigger_repo = None

for repo_dir in repos:
repo = Repository(**get_repo_data(repo_dir))
repositories.append(repo)
if repo.name == 'openvino':
version_file = Path(repo_dir) / 'src' / 'core' / 'include' / 'openvino' / 'core' / 'version.hpp'
ov_version = parse_ov_version(version_file)
if repo.trigger:
trigger_repo = repo

custom_branch_name = f'-{trigger_repo.branch}' if trigger_repo.branch != 'master' else ''
run_number_postfix = f'-{os.environ.get("GITHUB_RUN_NUMBER")}' if os.environ.get("GITHUB_RUN_NUMBER") else ''
product_version = f"{ov_version}{run_number_postfix}-{trigger_repo.revision[:11]}{custom_branch_name}"
ci_build_dev_tag = f'dev{trigger_repo.commit_time.strftime("%Y%m%d")}'
wheel_product_version = f'{ov_version}.{ci_build_dev_tag}'

set_github_output('CI_BUILD_NUMBER', product_version, 'GITHUB_ENV')
set_github_output('CI_BUILD_DEV_TAG', ci_build_dev_tag, 'GITHUB_ENV')

component = Component(name=component_name, version=product_version, product_type=product_type,
target_arch=target_arch, build_type=build_type, build_event=event_type,
repositories=repositories, custom_params={'wheel_product_version': wheel_product_version})

manifest.add_component(component)
return manifest


def main():
init_logger()
logger = logging.getLogger(__name__)
args = parse_args()

event_name = args.event_name or os.getenv('GITHUB_EVENT_NAME')
event_type = 'pre_commit' if event_name == 'pull_request' else 'commit'

repos = args.repos.split()
manifest = generate_manifest(repos, args.product_type, event_type, args.build_type, args.target_arch)

logger.info(f"Saving manifest to {args.save_to}")
manifest.save_manifest(args.save_to)


if __name__ == '__main__':
main()
Loading

0 comments on commit 76dbce1

Please sign in to comment.