Skip to content

Commit 4bfe725

Browse files
authored
[GHA] OV provider interface updates (openvinotoolkit#26636)
1 parent 1e3160d commit 4bfe725

File tree

9 files changed

+244
-103
lines changed

9 files changed

+244
-103
lines changed

.github/actions/common/artifact_utils.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44
import os
55
from pathlib import Path
6-
from .constants import EventType, ProductType
6+
from .constants import EventType, ProductType, PlatformKey
77

88

99
def add_common_args(parser: argparse.ArgumentParser):
@@ -12,10 +12,14 @@ def add_common_args(parser: argparse.ArgumentParser):
1212
default=os.getenv('GITHUB_BASE_REF') or os.getenv('GITHUB_REF_NAME'))
1313
parser.add_argument('-e', '--event_name', help='Name of GitHub event', required=False,
1414
default=os.getenv('GITHUB_EVENT_NAME'))
15-
parser.add_argument('--storage_dir', help='Subdirectory name for artifacts, same as product type', required=True,
16-
choices=[product_type.value for product_type in ProductType])
1715
parser.add_argument('--storage_root', help='Root path of the artifacts storage', required=False,
1816
default=os.getenv('ARTIFACTS_SHARE'))
17+
group = parser.add_mutually_exclusive_group(required=True)
18+
group.add_argument('-d', '--storage_dir', help='Subdirectory name for artifacts, same as product type',
19+
choices=[platform_key.value for platform_key in ProductType])
20+
group.add_argument('-p', '--platform', type=str,
21+
help='Platform for which to restore artifacts. Used if storage_dir is not set',
22+
choices=[product_type.value for product_type in PlatformKey])
1923

2024

2125
def get_event_type(event_name: str = os.getenv('GITHUB_EVENT_NAME')) -> str:

.github/actions/common/constants.py

+24
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,27 @@ class EventType(Enum):
1818
'public_windows_vs2019_Debug',
1919
)
2020
ProductType = Enum('ProductType', {t.upper(): t for t in productTypes})
21+
22+
23+
platformKeys = (
24+
'centos7_x86_64',
25+
'debian10_armhf',
26+
'rhel8_x86_64',
27+
'ubuntu20_arm64',
28+
'ubuntu20_x86_64',
29+
'ubuntu22_x86_64',
30+
'ubuntu24_x86_64',
31+
'macos_12_6_arm64',
32+
'macos_12_6_x86_64',
33+
'windows_x86_64',
34+
)
35+
PlatformKey = Enum('PlatformKey', {t.upper(): t for t in platformKeys})
36+
37+
PlatformMapping = {
38+
PlatformKey.DEBIAN10_ARMHF: ProductType.PUBLIC_LINUX_DEBIAN_10_ARM_RELEASE,
39+
PlatformKey.UBUNTU20_X86_64: ProductType.PUBLIC_LINUX_UBUNTU_20_04_X86_64_RELEASE,
40+
PlatformKey.UBUNTU20_ARM64: ProductType.PUBLIC_LINUX_UBUNTU_20_04_ARM64_RELEASE,
41+
PlatformKey.UBUNTU22_X86_64: ProductType.PUBLIC_LINUX_UBUNTU_22_04_X86_64_RELEASE,
42+
PlatformKey.UBUNTU24_X86_64: ProductType.PUBLIC_LINUX_UBUNTU_24_04_X86_64_RELEASE,
43+
PlatformKey.WINDOWS_X86_64: ProductType.PUBLIC_WINDOWS_VS2019_RELEASE,
44+
}

.github/actions/openvino_provider/action.yml

+96-61
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ name: 'OpenVINO provider'
22
description: 'Provides OpenVINO build artifacts from a requested source'
33
inputs:
44
revision:
5-
description: 'Version of OpenVINO to provide - latest_available | HEAD | specific commit hash'
5+
description: 'Version of OpenVINO to provide - latest_available_commit | HEAD | specific commit hash |
6+
latest_nightly | specific package version (e.g. 2024.4.0rc2)'
67
required: true
78
branch_name:
89
description: 'Branch of OpenVINO to take the revision from if no specific hash was provided.
@@ -11,21 +12,25 @@ inputs:
1112
ov_artifact_name:
1213
description: "Name under which to upload provided OpenVINO build artifacts, set automatically by default"
1314
required: false
15+
platform:
16+
description: "Platform for which to get artifacts: centos7 | debian10 | rhel8 | ubuntu20 |
17+
ubuntu20 | ubuntu22 | ubuntu24 | macos | macos_12_6 | windows"
18+
required: false
19+
arch:
20+
description: "Architecture for which to get artifacts: x86_64 | armhf | arm64"
21+
default: "x86_64"
22+
required: false
23+
install_dir:
24+
description: 'Local path to install OpenVINO package to. If not specified, package is installed to GitHub workspace
25+
and uploaded to GitHub'
26+
required: false
1427
commit_packages_to_provide:
1528
description: "Comma-separated list of OpenVINO packages from post-commit to provide ('all' to get everything)"
1629
required: false
17-
commit_build_key:
18-
description: 'public_linux_ubuntu_20_04_release | public_linux_ubuntu_22_04_release |
19-
public_linux_ubuntu_24_04_release | public_windows_vs2019_release'
20-
required: false
2130
commit_share_path:
2231
description: 'Path to share holding OpenVINO post-commit artifacts'
2332
required: false
2433
default: '/mount/build-artifacts'
25-
nightly_build_key:
26-
description: 'centos7_x86_64 | debian9_armhf | rhel8_x86_64 | ubuntu20_arm64 | ubuntu20_x86_64 | ubuntu22_x86_64 |
27-
ubuntu24_x86_64 | macos_12_6_arm64 | macos_12_6_x86_64 | windows_x86_64'
28-
required: false
2934
nightly_package_source:
3035
description: 'Source URL hosting OpenVINO nightly archives'
3136
required: false
@@ -34,40 +39,44 @@ inputs:
3439
description: 'Source URL hosting OpenVINO wheels, for passing to pip as --extra-index-url'
3540
required: false
3641
default: 'https://storage.openvinotoolkit.org/simple/wheels'
37-
package_url:
38-
description: 'Direct URL to OpenVINO archive to use, if neither post-commit nor nightly archives are required'
39-
required: false
42+
4043
outputs:
4144
ov_artifact_name:
4245
description: "Name of the artifact to upload OpenVINO build artifacts under"
43-
value: ${{ steps.openvino_download.outputs.ov_artifact_name || steps.openvino_commit_output.outputs.ov_artifact_name }}
44-
ov_package_path:
45-
description: "Path to OpenVINO core package relative to the root of uploaded artifacts"
46-
value: ${{ steps.openvino_download.outputs.ov_package_path || steps.openvino_commit_output.outputs.ov_package_path }}
47-
ov_wheel_input:
48-
description: "Input for pip to install OpenVINO python wheel"
49-
value: ${{ steps.openvino_wheel.outputs.ov_wheel_input || steps.openvino_commit_wheel.outputs.ov_wheel_input }}
46+
value: ${{ steps.openvino_s3_download.outputs.ov_artifact_name || steps.openvino_commit_output.outputs.ov_artifact_name }}
5047
ov_wheel_source:
5148
description: "Pip option for custom OV wheel location (--find-links or --extra-index-url)"
52-
value: ${{ steps.openvino_wheel.outputs.ov_wheel_source || steps.openvino_commit_wheel.outputs.ov_wheel_source }}
49+
value: ${{ steps.openvino_s3_wheel.outputs.ov_wheel_source || steps.openvino_commit_wheel.outputs.ov_wheel_source }}
50+
ov_version:
51+
description: "OpenVINO product version"
52+
value: ${{ steps.openvino_s3_wheel.outputs.ov_version || steps.openvino_commit_wheel.outputs.ov_version }}
5353

5454
runs:
5555
using: "composite"
5656
steps:
57-
- name: Verify parameters
58-
if: ${{ !inputs.package_url && !inputs.nightly_build_key && !inputs.commit_build_key }}
57+
- name: Identify artifacts source
58+
id: get_source
5959
shell: bash
6060
run: |
61-
echo "Please, set one parameter for action - nightly_build_key, commit_build_key or package_url"
62-
exit 1
61+
artifacts_source="postcommit"
62+
if [[ "${{ inputs.revision }}" == "latest_nightly" || "${{ inputs.revision }}" =~ ^[0-9]{4}\.[0-9]+\.*[0-9]* ]]; then
63+
artifacts_source="s3"
64+
fi
65+
echo "artifacts_source=$artifacts_source" >> $GITHUB_OUTPUT
66+
67+
- name: Get action revision
68+
id: get_action_revision
69+
run: echo "action_ref=${{ env.ACTION_REF }}" >> $GITHUB_OUTPUT
70+
shell: bash
71+
env:
72+
ACTION_REF: ${{ github.action_ref || github.base_ref || github.event.merge_group.base_ref || github.ref }}
6373

6474
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
6575
with:
6676
repository: 'openvinotoolkit/openvino'
67-
ref: ${{ inputs.branch_name || github.base_ref || github.event.merge_group.base_ref || github.ref }}
77+
ref: ${{ steps.get_action_revision.outputs.action_ref }}
6878
sparse-checkout: .github/actions
6979

70-
# --- Post-commit case ---
7180
- name: Clone OpenVINO to get HEAD commit
7281
if: inputs.revision == 'HEAD'
7382
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -84,18 +93,25 @@ runs:
8493
head=$(git -C openvino rev-parse HEAD)
8594
echo "head=$head" >> $GITHUB_OUTPUT
8695
96+
- name: Create install dir
97+
if: inputs.install_dir
98+
shell: bash
99+
run: |
100+
mkdir -p ${{ inputs.install_dir }}
101+
102+
# --- Post-commit case ---
87103
- name: Download post-commit OpenVINO archives
88104
id: openvino_commit_download
89-
if: inputs.commit_build_key
105+
if: steps.get_source.outputs.artifacts_source == 'postcommit'
90106
uses: ./.github/actions/restore_artifacts
91107
with:
92-
storage_dir: ${{ inputs.commit_build_key }}
108+
platform: ${{ inputs.platform }}_${{ inputs.arch }}
93109
storage_root: ${{ inputs.commit_share_path }}
94110
event_name: "commit"
95111
trigger_repo_sha: ${{ env.OV_REVISION }}
96112
branch_name: ${{ inputs.branch_name }}
97-
artifacts_key: ${{ inputs.ov_artifact_name || inputs.commit_build_key }}
98113
to_restore: ${{ inputs.commit_packages_to_provide }}
114+
target_dir: ${{ inputs.install_dir }}
99115
env:
100116
OV_REVISION: ${{ inputs.revision == 'HEAD' && steps.get_openvino_head_commit.outputs.head || inputs.revision }}
101117

@@ -104,79 +120,98 @@ runs:
104120
if: steps.openvino_commit_download.outcome == 'success'
105121
shell: bash
106122
run: |
107-
ov_artifact_name=${{ inputs.ov_artifact_name || steps.openvino_commit_download.outputs.restored_artifacts_key }}
108-
cd ${{ steps.openvino_commit_download.outputs.artifacts_workspace_path }}
123+
ov_artifact_name=${{ inputs.ov_artifact_name || inputs.platform }}
124+
workspace_path=${{ steps.openvino_commit_download.outputs.artifacts_path }}
125+
cd $workspace_path
109126
ov_package_path=$(find . -name 'openvino_package*' -printf "%P\n" -quit)
110127
[ -z "$ov_package_path" ] && echo "No openvino_package found in restored artifacts" && exit 1
128+
mv $ov_package_path/* . && rm -rf $ov_package_path
111129
echo "ov_artifact_name=$ov_artifact_name" >> $GITHUB_OUTPUT
112-
echo "ov_package_path=$ov_package_path" >> $GITHUB_OUTPUT
130+
echo "ov_package_path=$workspace_path" >> $GITHUB_OUTPUT
113131
114132
- name: Get commit wheel
115133
id: openvino_commit_wheel
116134
if: steps.openvino_commit_download.outcome == 'success'
117135
shell: bash
118136
run: |
119-
cd ${{ steps.openvino_commit_download.outputs.artifacts_workspace_path }}
137+
artifacts_path=${{ steps.openvino_commit_download.outputs.artifacts_path }}
138+
cd $artifacts_path
120139
version=$(yq eval '.components.dldt.custom_params.wheel_product_version' manifest.yml)
121-
wheel_path=${{ steps.openvino_commit_output.outputs.ov_package_path }}/tools
122-
default_find_links_cmd="--find-links=./$wheel_path"
140+
wheel_path=${{ inputs.install_dir && '$artifacts_path/tools' || './tools' }}
141+
default_find_links_cmd="--find-links=$wheel_path"
123142
find_links_cmd=$([[ -n "$PIP_FIND_LINKS" ]] && echo "" || echo "$default_find_links_cmd")
124-
wheel_input="$find_links_cmd openvino==$version"
125-
echo "ov_wheel_input=$wheel_input" >> $GITHUB_OUTPUT
143+
echo "ov_version=$version" >> $GITHUB_OUTPUT
126144
echo "ov_wheel_source=$default_find_links_cmd" >> $GITHUB_OUTPUT
127145
146+
- name: Upload commit OpenVINO archives
147+
if: steps.openvino_commit_download.outcome == 'success' && !inputs.install_dir
148+
uses: actions/upload-artifact@v4
149+
with:
150+
name: ${{ steps.openvino_commit_output.outputs.ov_artifact_name }}
151+
path: ${{ steps.openvino_commit_output.outputs.ov_package_path }}
152+
if-no-files-found: 'error'
128153

129-
# --- S3 case (nightly or direct URL) ---
130-
- name: Verify parameters
131-
if: (inputs.nightly_build_key || inputs.package_url) && inputs.revision != 'latest_available'
154+
# --- S3 case ---
155+
- name: Get a specific S3 package URL
156+
id: get_s3_package
157+
if: steps.get_source.outputs.artifacts_source == 's3' && inputs.revision != 'latest_nightly'
132158
shell: bash
133-
run: |
134-
echo "Nightly and package_url build sources provide only 'latest' artifacts, specific revision not supported"
135-
exit 1
159+
run: >-
160+
python3 -m venv venv && . venv/bin/activate &&
161+
pip install -r $GITHUB_ACTION_PATH/requirements.txt &&
162+
python $GITHUB_ACTION_PATH/get_s3_package.py --product openvino --platform ${{ inputs.platform }} --arch ${{ inputs.arch }}
163+
--version ${{ inputs.revision }}
136164
137-
- name: Download OpenVINO archives
138-
id: openvino_download
139-
if: inputs.nightly_build_key || inputs.package_url
165+
- name: Download nightly OpenVINO archives
166+
id: openvino_s3_download
167+
if: steps.get_source.outputs.artifacts_source == 's3'
140168
shell: bash
141169
run: |
142-
if [ ${{ inputs.package_url }} ]; then
143-
ov_package_url=${{ inputs.package_url }}
170+
if [ ${{ steps.get_s3_package.outcome }} != 'skipped' ]; then
171+
ov_package_url=${{ steps.get_s3_package.outputs.package_url }}
144172
else
145-
ov_package_url=$(curl -s ${{ inputs.nightly_package_source }} | jq -r '.${{ inputs.nightly_build_key }}')
173+
ov_package_url=$(curl -s ${{ inputs.nightly_package_source }} | jq -r '.${{ inputs.platform }}_${{ inputs.arch }}')
146174
fi
175+
cd ${{ inputs.install_dir || env.GITHUB_WORKSPACE }}
147176
package_basename=$(basename $ov_package_url)
148177
wget $ov_package_url --progress=bar:force:noscroll -O $package_basename
149-
package_folder=${package_basename%.*} && mkdir $package_folder
150-
[[ "$package_basename" == *.zip ]] && unzip "$package_basename" -d $package_folder || tar -xvf "$package_basename" -C $package_folder
178+
package_folder=${package_basename%.*}
179+
[[ "$package_basename" == *.zip ]] && unzip "$package_basename" || tar -xvf "$package_basename"
180+
rm $package_basename
181+
if [ ${{ inputs.install_dir }} ]; then
182+
mv $package_folder/* . && rm -rf $package_folder
183+
fi
151184
ov_artifact_name=$([ ${{ inputs.ov_artifact_name }} ] && echo ${{ inputs.ov_artifact_name }} || echo $package_folder)
185+
echo "ov_package_url=$ov_package_url" >> $GITHUB_OUTPUT
152186
echo "ov_artifact_name=$ov_artifact_name" >> $GITHUB_OUTPUT
153187
echo "ov_package_path=$package_folder" >> $GITHUB_OUTPUT
154188
155189
- name: Upload OpenVINO archives
156-
if: steps.openvino_download.outcome == 'success'
190+
if: steps.openvino_s3_download.outcome == 'success' && !inputs.install_dir
157191
uses: actions/upload-artifact@v4
158192
with:
159-
name: ${{ steps.openvino_download.outputs.ov_artifact_name }}
160-
path: ${{ steps.openvino_download.outputs.ov_package_path }}
193+
name: ${{ steps.openvino_s3_download.outputs.ov_artifact_name }}
194+
path: ${{ steps.openvino_s3_download.outputs.ov_package_path }}
161195
if-no-files-found: 'error'
162196

163197
- name: Get wheel
164-
id: openvino_wheel
165-
if: steps.openvino_download.outcome == 'success'
198+
id: openvino_s3_wheel
199+
if: steps.openvino_s3_download.outcome == 'success'
166200
shell: bash
167201
run: |
168-
rc_version=$(echo ${{ inputs.package_url }} |
202+
rc_version=$(echo ${{ steps.openvino_s3_download.outputs.ov_package_url }} |
169203
grep -oP '(?<=pre-release\/)\d{4}\.\d+\.\d+rc\d+' || true)
170204
171-
release_version=$(echo ${{ steps.openvino_download.outputs.ov_package_path }} |
205+
release_version=$(echo ${{ steps.openvino_s3_download.outputs.ov_package_path }} |
172206
grep -oP '_\K\d{4}\.\d+\.\d+')
173207
174-
dev_version=$(echo ${{ steps.openvino_download.outputs.ov_package_path }} |
208+
dev_version=$(echo ${{ steps.openvino_s3_download.outputs.ov_package_path }} |
175209
grep -oP "${release_version//./\\.}\.dev\d{8}" || true)
176210
177211
version=${rc_version:-${dev_version:-$release_version}}
212+
178213
extra_index="--pre --extra-index-url ${{ inputs.pip_extra_url }}/nightly \
179214
--extra-index-url ${{ inputs.pip_extra_url }}/pre-release"
180-
wheel_input="$extra_index openvino==$version"
181-
echo "ov_wheel_input=$wheel_input" >> $GITHUB_OUTPUT
215+
216+
echo "ov_version=$version" >> $GITHUB_OUTPUT
182217
echo "ov_wheel_source=$extra_index" >> $GITHUB_OUTPUT
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import requests
2+
import re
3+
import argparse
4+
import logging
5+
import sys
6+
7+
from pathlib import Path
8+
9+
sys.path.append(str(Path(__file__).parents[1]))
10+
from common import action_utils
11+
12+
13+
# Function to download the JSON file
14+
def load_json_file(url):
15+
response = requests.get(url)
16+
if response.status_code == 200:
17+
return response.json()
18+
else:
19+
raise Exception(f"Failed to download the file, status code: {response.status_code}")
20+
21+
22+
# Function to recursively gather all file paths from the JSON structure
23+
def gather_all_files(node, base_path=''):
24+
all_files = []
25+
if 'children' in node:
26+
for child in node['children']:
27+
new_base = f"{base_path}/{child['name']}"
28+
if 'children' in child:
29+
all_files += gather_all_files(child, new_base)
30+
else:
31+
all_files.append(new_base)
32+
return all_files
33+
34+
35+
# Function to filter files based on the product, version, platform, architecture, and folder
36+
def filter_files_by_criteria(files, product, version_pattern, platform, arch, folder):
37+
matching_files = []
38+
for file in files:
39+
if re.search(
40+
fr"{product}/packages/{folder}(/?.*/)?{version_pattern}/.*{platform}.*{arch}.*\.(tar\.gz|tgz|zip)$",
41+
file):
42+
matching_files.append(file)
43+
return matching_files
44+
45+
46+
# Main function to load the JSON, gather file paths, and filter based on criteria
47+
def main(product, version_pattern, platform, arch, folder):
48+
action_utils.init_logger()
49+
logger = logging.getLogger(__name__)
50+
51+
url = 'https://storage.openvinotoolkit.org/filetree.json'
52+
filetree = load_json_file(url)
53+
all_files = gather_all_files(filetree)
54+
matching_files = filter_files_by_criteria(all_files, product, version_pattern, platform, arch, folder)
55+
if matching_files:
56+
logger.info(f"Matching packages: {sorted(matching_files)}")
57+
package_url = f"https://storage.openvinotoolkit.org{sorted(matching_files)[-1]}"
58+
logger.info(f"Returning package URL: {package_url}")
59+
action_utils.set_github_output("package_url", package_url)
60+
else:
61+
logger.error("No matching files found.")
62+
sys.exit(1)
63+
64+
65+
if __name__ == "__main__":
66+
parser = argparse.ArgumentParser(
67+
description='Search OpenVINO archives based on product, version, platform, architecture, and folder.')
68+
parser.add_argument('--product', required=True, choices=['openvino', 'openvino_genai', 'openvino_tokenizers'],
69+
help='Product name')
70+
parser.add_argument('--version', required=True, help='Version pattern (supports regex)')
71+
parser.add_argument('--platform', default='ubuntu22', help='Platform (default: ubuntu22)')
72+
parser.add_argument('--arch', default='x86_64', help='Architecture (default: x86_64)')
73+
parser.add_argument('--folder', default='(.*/)?', help='Folder type (e.g., pre-release, nightly, default: (.*)?')
74+
75+
args = parser.parse_args()
76+
77+
main(args.product, args.version, args.platform, args.arch, args.folder)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests~=2.32

0 commit comments

Comments
 (0)