Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 57 additions & 54 deletions ci/get_changed_bundle.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
# Copyright (c) MONAI Consortium
# 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 argparse

from utils import get_changed_bundle_list


def get_changed_bundle(changed_dirs):
"""
This function is used to get all changed bundles, a string which
contains all bundle names will be printed, and can be used in shell scripts.
"""
bundle_names = ""
root_path = "models"
bundle_list = get_changed_bundle_list(changed_dirs, root_path=root_path)

for bundle in bundle_list:
bundle_names += f"{bundle} "
print(bundle_names)


def get_changed_hf_model(changed_dirs):
"""
This function is used to get all changed hf models, a string which
contains all hf model names will be printed, and can be used in shell scripts.
"""
hf_model_names = ""
root_path = "hf_models"
hf_model_list = get_changed_bundle_list(changed_dirs, root_path=root_path)
for hf_model in hf_model_list:
hf_model_names += f"{hf_model} "
print(hf_model_names)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="")
parser.add_argument("-f", "--f", type=str, help="changed files.")
parser.add_argument("--hf_model", type=bool, default=False, help="if true, get changed hf models.")
args = parser.parse_args()
changed_dirs = args.f.splitlines()
if args.hf_model:
get_changed_hf_model(changed_dirs)
else:
get_changed_bundle(changed_dirs)
# Copyright (c) MONAI Consortium
# 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 argparse

from utils import get_changed_bundle_list


def get_changed_bundle(changed_dirs, filter_docs=False):
"""
This function is used to get all changed bundles, a string which
contains all bundle names will be printed, and can be used in shell scripts.
"""
bundle_names = ""
root_path = "models"
bundle_list = get_changed_bundle_list(changed_dirs, root_path=root_path, filter_docs=filter_docs)

for bundle in bundle_list:
bundle_names += f"{bundle} "
print(bundle_names)


def get_changed_hf_model(changed_dirs, filter_docs=False):
"""
This function is used to get all changed hf models, a string which
contains all hf model names will be printed, and can be used in shell scripts.
"""
hf_model_names = ""
root_path = "hf_models"
hf_model_list = get_changed_bundle_list(changed_dirs, root_path=root_path, filter_docs=filter_docs)
for hf_model in hf_model_list:
hf_model_names += f"{hf_model} "
print(hf_model_names)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="")
parser.add_argument("-f", "--f", type=str, help="changed files.")
parser.add_argument("--hf_model", action="store_true", help="if true, get changed hf models.")
parser.add_argument(
"--filter_docs", action="store_true", help="if true, skip bundles with documentation-only changes."
)
args = parser.parse_args()
changed_dirs = args.f.splitlines()
if args.hf_model:
get_changed_hf_model(changed_dirs, filter_docs=args.filter_docs)
else:
get_changed_bundle(changed_dirs, filter_docs=args.filter_docs)
4 changes: 2 additions & 2 deletions ci/run_premerge_cpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ verify_bundle() {
if [ ! -z "$changes" ]
then
# get all changed bundles
bundle_list=$(python $(pwd)/ci/get_changed_bundle.py --f "$changes")
bundle_list=$(python $(pwd)/ci/get_changed_bundle.py --f "$changes" --filter_docs)
if [ ! -z "$bundle_list" ]
then
python $(pwd)/ci/prepare_schema.py --l "$bundle_list"
Expand Down Expand Up @@ -128,7 +128,7 @@ verify_bundle() {
if [ ! -z "$hf_model_changes" ]
then
# get all changed hf models
hf_model_list=$(python $(pwd)/ci/get_changed_bundle.py --f "$hf_model_changes" --hf_model True)
hf_model_list=$(python $(pwd)/ci/get_changed_bundle.py --f "$hf_model_changes" --hf_model --filter_docs)
if [ ! -z "$hf_model_list" ]
then
python $(pwd)/ci/prepare_schema.py --l "$hf_model_list" --p "hf_models"
Expand Down
Loading