Пример #1
0
def subprocess_main(framework=None):
    """
        Please keep this file compatible with python2 in order to check user python version.

        This function checks that Inference Engine Python API available and working as expected
        and then in sub-process it executes main_<fw>.py files. Due to some OSs specifics we can't
        just add paths to Python modules and libraries into current env. So to make Inference Engine
        Python API to be available inside MO we need to use subprocess with new env.
    """
    ret_code = check_python_version()
    if ret_code:
        sys.exit(ret_code)

    from mo.utils.find_ie_version import find_ie_version
    find_ie_version(silent=True)

    mo_root_path = os.path.join(os.path.dirname(__file__), os.pardir)

    python_path_key = 'PYTHONPATH'
    if python_path_key not in os.environ:
        os.environ[python_path_key] = mo_root_path
    else:
        os.environ[python_path_key] = os.pathsep.join(
            [os.environ[python_path_key], mo_root_path])

    path_to_main = os.path.join(
        os.path.realpath(os.path.dirname(__file__)),
        'main_{}.py'.format(framework) if framework else 'main.py')
    # python2 compatible code. Do not remove.
    args = [sys.executable, path_to_main]
    for arg in sys.argv[1:]:
        args.append(arg)
    status = subprocess.run(args, env=os.environ)
    sys.exit(status.returncode)
Пример #2
0
def setup_env():
    ret_code = check_python_version()
    if ret_code:
        sys.exit(ret_code)

    from mo.utils.find_ie_version import find_ie_version

    ie_found = True
    try:
        ie_found = find_ie_version(silent=True)
    except Exception:
        ie_found = False

    if not ie_found:
        log_ie_not_found()
        sys.exit(1)

    mo_root_path = os.path.join(os.path.dirname(__file__), os.pardir)

    python_path_key = 'PYTHONPATH'
    if python_path_key not in os.environ:
        os.environ[python_path_key] = mo_root_path
    else:
        os.environ[python_path_key] = os.pathsep.join([os.environ[python_path_key], mo_root_path])
    return True
Пример #3
0
def converter_main():
    warnings.filterwarnings("ignore", category=FutureWarning)
    warnings.filterwarnings("ignore", category=DeprecationWarning)
    ret_code = check_python_version()
    if ret_code:
        sys.exit(ret_code)

    from mo.main import main
    from mo.utils.cli_parser import get_all_cli_parser  # pylint: disable=no-name-in-module

    sys.exit(main(get_all_cli_parser(), None))
Пример #4
0
def setup_env():
    ret_code = check_python_version()
    if ret_code:
        sys.exit(ret_code)

    from mo.utils.find_ie_version import find_ie_version
    find_ie_version(silent=True)

    mo_root_path = os.path.join(os.path.dirname(__file__), os.pardir)

    python_path_key = 'PYTHONPATH'
    if python_path_key not in os.environ:
        os.environ[python_path_key] = mo_root_path
    else:
        os.environ[python_path_key] = os.pathsep.join(
            [os.environ[python_path_key], mo_root_path])
Пример #5
0
#!/usr/bin/env python3
"""
 Copyright (C) 2018-2021 Intel Corporation

 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 sys

from mo.utils.versions_checker import check_python_version

if __name__ == "__main__":
    ret_code = check_python_version()
    if ret_code:
        sys.exit(ret_code)

    from mo.main import main
    from mo.utils.cli_parser import get_caffe_cli_parser

    sys.exit(main(get_caffe_cli_parser(), 'caffe'))