-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Bundling demos as release asset (#5550)
- Loading branch information
1 parent
6a5d8eb
commit b7053f4
Showing
3 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,61 @@ | ||
# Copyright 2019 Iguazio | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
import os | ||
import shutil | ||
import tarfile | ||
|
||
from git import Repo | ||
|
||
# List of repositories to archive | ||
repos = [ | ||
{"url": "https://github.com/mlrun/demo-azure-ML.git", "name": "demo-azure-ML"}, | ||
{"url": "https://github.com/mlrun/demo-fraud.git", "name": "demo-fraud"}, | ||
{ | ||
"url": "https://github.com/mlrun/demo-mask-detection.git", | ||
"name": "demo-mask-detection", | ||
}, | ||
# Add more repositories as needed | ||
] | ||
|
||
# Directory where repositories will be cloned and extracted | ||
temp_dir = "demos" | ||
|
||
# Create the temporary directory if it doesn't exist | ||
os.makedirs(temp_dir, exist_ok=True) | ||
|
||
# Clone each repository and extract its contents to the temporary directory | ||
for repo_info in repos: | ||
print(f"cloning {repo_info['url']} with name {repo_info['name']} to {temp_dir}") | ||
repo_url = repo_info["url"] | ||
repo_name = repo_info["name"] | ||
|
||
# Clone the repository | ||
try: | ||
repo = Repo.clone_from(repo_url, os.path.join(temp_dir, repo_name)) | ||
except Exception as e: | ||
print(f"could not clone repo {repo_url}") | ||
print(e) | ||
|
||
# Copying update_demos.sh from mlrun | ||
shutil.copyfile("automation/scripts/update_demos.sh", "demos/update_demos.sh") | ||
|
||
# Create a tar archive of the temporary directory | ||
with tarfile.open("mlrun-demos.tar", "w") as tar: | ||
tar.add(temp_dir, arcname=os.path.basename(temp_dir)) | ||
|
||
print("Archive created successfully!") | ||
|
||
# Cleanup: Delete the temporary directory | ||
shutil.rmtree(temp_dir) |
This file contains 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,64 @@ | ||
# Copyright 2019 Iguazio | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
error_exit() | ||
{ | ||
|
||
# ---------------------------------------------------------------- | ||
# Function for exit due to fatal program error | ||
# Accepts 1 argument: | ||
# string containing descriptive error message | ||
# ---------------------------------------------------------------- | ||
echo "${SCRIPT}: ${1:-"Unknown Error"}" 1>&2 | ||
exit 1 | ||
} | ||
|
||
user=${V3IO_USERNAME} | ||
demos_dir=$(echo "/v3io/users/${user}") | ||
pip_mlrun=$(pip show mlrun | grep Version) | ||
|
||
# Grepping mlrun version | ||
if [ -z "${pip_mlrun}" ]; then | ||
error_exit "MLRun version not found. Aborting..." | ||
fi | ||
|
||
# Extracting mlrun version and adding "-" between version prefix and rc | ||
mlrun_version=$(echo "${pip_mlrun##Version: }" | sed 's/\([0-9]\)rc/\1-rc/') | ||
echo "Detected MLRun version: ${mlrun_version}" | ||
|
||
# Verifying mlrun >= 1.7 | ||
tag_prefix=`echo ${mlrun_version} | cut -d . -f1-2` | ||
if [[ "${tag_prefix}" < "1.7" ]]; then | ||
error_exit "MLRun version must be 1.7 or above, for older updates run: sh https://raw.githubusercontent.com/mlrun/demos/v1.6.0/update_demos.sh .Aborting..." | ||
fi | ||
|
||
# copy & remove old demos folder | ||
dt=$(date '+%Y%m%d%H%M%S'); | ||
old_demos_dir="${HOME}/demos.old/${dt}" | ||
demos_dir="${HOME}/demos" | ||
echo "Moving existing '${demos_dir}' to ${old_demos_dir}'..." | ||
mkdir -p "${old_demos_dir}" | ||
cp -r "${demos_dir}/." "${old_demos_dir}" && rm -rf "${demos_dir}" | ||
|
||
# Making of git url that holds tar asset | ||
# e.g. https://github.com/mlrun/mlrun/releases/download/v1.7.0-rc3/mlrun-demos.tar | ||
tar_url=$(echo "https://github.com/mlrun/mlrun/releases/download/v${mlrun_version}/mlrun-demos.tar") | ||
|
||
# Downloading & extracting tar | ||
wget ${tar_url} | ||
mkdir ${demos_dir} | ||
tar -xvf mlrun-demos.tar -C ${demos_dir} --strip-components 1 | ||
|
||
# Cleaning | ||
rm -rf demos.tar |