Files
openvino/tools/mo/automation/utils.py
T
Pavel Esir 980904c9ec [MO] Align MO namespaces (#7708)
* Moved and merged mo/ and extensions/ into openvino/tools/mo

* edited imports

* edited docs to use mo script from entry_point

* edited MO transformations list loading and setup.py

* changed full path -> 'mo' entry point in docs (leftovers)

* corrected package_BOM

* updated resolving --transformation_config in cli_parser.py

* pkgutil-style __init__.py, added summarize_graph into entry points

* updated DOCs for the new --transformations_config

* fix select

* updated install instructions, fixed setup.py for windows and python_version < 3.8

* fixed typo in requirements.txt

* resolved conflicts

* removed creating custom __init__.py from setup.py

* corrected folder with caffe proto

* corrected loading user defined extensions

* fix openvino.tools.mo import in serialize.py

* corrected layer tests for new namespace

* fix in get_testdata.py

* moved model-optimizer into tools/

* renamed import in POT

* corrected mo.yml

* correct CMakeLists.txt for the newest tools/mo

* corrected find_ie_version.py

* docs and openvino-dev setup.py update for the newest tools/mo

* miscellaneous leftovers and fixes

* corrected CI files, pybind11_add_module in CMakeLists.txt and use of tools/mo path instead of tools/model_optimizer

* add_subdirectory pybind11 for tools/mo

* POT path fix

* updated setupvars.sh setupvars.bat

* Revert "updated setupvars.sh setupvars.bat"

This reverts commit c011142340.

* removed model-optimizer env variables from setupvars

* updated CMakeLists.txt to pack MO properly with tests component

* corrected left imports, corrected loading requirements for layer tests

* mo doc typo correction

* minor corrections in docs; removed summarize_graph from entry_points

* get_started_windows.md, MonoDepth_how_to.md corrections, mo path corrections
2021-12-08 08:53:53 +03:00

51 lines
1.6 KiB
Python

# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import os
import subprocess
import tarfile
from datetime import datetime
from shutil import copy, copytree, rmtree
class Automation:
@staticmethod
def parse_bom(bom_path):
files = []
for file in open(bom_path):
files.append(file)
return files
@staticmethod
def copy_files_from_bom(root_path, bom):
target_dir = os.path.join(os.path.dirname(__file__), "ModelOptimizerForTensorflow")
if os.path.exists(target_dir):
rmtree(target_dir)
os.makedirs(target_dir)
for file in bom:
src = os.path.join(root_path, file.strip('\n'))
dst = os.path.join(target_dir, file.strip('\n'))
if not os.path.exists(os.path.dirname(dst)):
os.makedirs(os.path.dirname(dst))
if os.path.isdir(src):
copytree(src, dst)
else:
copy(src, dst)
return target_dir
@staticmethod
def add_version_txt(dst_path, build_number):
timestamp = datetime.now().strftime("%I:%M%p %B %d, %Y")
with open(os.path.join(dst_path, "version.txt"), 'w') as f:
f.write(timestamp + '\n')
f.write(build_number + '\n')
@staticmethod
def make_tarfile(out_file_name, source_dir):
archive_path = os.path.join(os.path.dirname(__file__), out_file_name)
if os.path.exists(archive_path):
os.remove(archive_path)
with tarfile.open(out_file_name, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir))