Esempio n. 1
0
        # Use tempfolder for cloning repository
        import tempfile, shutil, atexit
        code_path = tempfile.mkdtemp()

        # automatically remove temp directory if process exits
        def cleanup():
            shutil.rmtree(code_path)

        atexit.register(cleanup)

        vcs.get_backend(vc_type).export(code_path, url=vcs_url)
        from pip._internal.models.link import Link
        subdir = Link(vcs_url).subdirectory_fragment
        if subdir:
            code_path = os.path.join(code_path, subdir.lstrip('/'))
    except Exception as ex:
        log.exception("Failed to clone repository via pip internal.")

if not code_path or not os.path.exists(code_path):
    log.info("No code artifacts could be found for " + EXECUTE_CODE)
    sys.exit(1)

# code script is the file that actually executed -> if directory it needs a main module
main_script = code_path
# Execute single script
if os.path.isfile(code_path):
    # set code path to the root folder of the script so it can also resolve conda env and requirements
    code_path = os.path.dirname(os.path.realpath(code_path))

# Execute code from folder -> this should always be a folder
Esempio n. 2
0
        import tempfile

        code_path = tempfile.mkdtemp()

        # automatically remove temp directory if process exits
        def cleanup():
            shutil.rmtree(code_path)

        atexit.register(cleanup)

        vcs.get_backend(vc_type).export(code_path, url=vcs_url)
        from pip._internal.models.link import Link

        subdir = Link(vcs_url).subdirectory_fragment
        if subdir:
            code_path = os.path.join(code_path, subdir.lstrip("/"))
    except Exception as ex:
        log.exception("Failed to clone repository via pip internal.")

if not code_path or not os.path.exists(code_path):
    log.info("No code artifacts could be found for " + EXECUTE_CODE)
    sys.exit(1)

# code script is the file that actually executed -> if directory it needs a main module
main_script = code_path
# Execute single script
if os.path.isfile(code_path):
    # set code path to the root folder of the script so it can also resolve conda env and requirements
    code_path = os.path.dirname(os.path.realpath(code_path))

# Execute code from folder -> this should always be a folder