Source Code Documentation

Main module

Server module

Migrator module

Package manager module

Base system script

This module runs on the base system as a Python script

The module mainly discovers the existing conda environments and sends the source code over to the target system for further processing.

NOTE:
The script should be compatible with both Python 2 and 3. It will be executed using whichever version of Python is available using python command.
platform_migrator.base_sys_script.create_zip_file(zip_dir, env_yml=None, min_deps=None, quiet=False)[source]

Create a zip file of a directory

Args:
zip_dir:The directory to zip
Kwargs:
env_yml=None (str):
 If provided, the string is copied as the env.yml file in the zip archive
min_deps=None (str):
 If provided, the string is copied as the min-deps.json file in the zip archive
quiet=False:If True, no messages are printed
Return:
A bytes buffer containing the zip file data
platform_migrator.base_sys_script.get_conda_env(env=None)[source]

Return the yml file of current conda environment

The function runs a subprocess to get the yml file of the current conda environment. The results of the subprocess are returned as a tuple and if the yml file was obtained, it will be index 1 of the tuple.

Kwargs:
env=None:Conda environment to source, if not the currently active environment.
Return:
A tuple whose elements are a boolean indicating whether the process ran error free, the stdout of the process and the stderr of the process
platform_migrator.base_sys_script.get_conda_min_deps(env, source_env=False)[source]

Try to create a list of minimal dependencies to install

The function queries the conda environment for all dependencies and then tries to determine the which dependencies are sub-dependencies of others. In this way, a minimal list of dependencies is created.

Args:
env:The name of the conda environment to query
Kwargs:
source_env=False:
 Boolean indicator whether to source conda env before getting data or not
Return:
A list of conda package objects if succesful, or None if the conda envrionment could not be loaded
platform_migrator.base_sys_script.main(cl_args=None, save_zip=None)[source]

Main function that is executed

Kwargs:
cl_args=None (argparse.Namespace):
 Any command line args that have been parsed.
save_zip=None (bool):
 If True, a zip file is created for saving without prompting the user. Otherwise, the user is prompted for the action.
platform_migrator.base_sys_script.parse_args()[source]

Parse the command line arguments when run as a script

Return:
An argparse.Namespace instance for the parsed arguments
platform_migrator.base_sys_script.send_data(app_name, path, data, name, quiet=False)[source]

Send data back to the server

Args:
app_name (str):The name of the application
path (str):The path to send data to, without the base address
data:Buffer containing the data
name (str):The name to use for the data in messages
Kwargs:
quiet=False (bool):
 If True, no messages are printed
platform_migrator.base_sys_script.send_env_yml(app_name, env_yml, quiet=False)[source]

Send the environment yml data back to the server

Args:
app_name (str):The name of the application
env_yml:Buffer containing the environment yml data
Kwargs:
quiet=False (bool):
 If True, no messages are printed
platform_migrator.base_sys_script.send_min_deps(app_name, min_deps, quiet=False)[source]

Send a zip of the repository back to the server

Args:
app_name (str):The name of the application
min_deps (list):
 List containing the minimal required dependencies
Kwargs:
quiet=False (bool):
 If True, no messages are printed
platform_migrator.base_sys_script.send_repo_zip(app_name, zip_file, quiet=False)[source]

Send a zip of the repository back to the server

Args:
app_name (str):The name of the application
zip_file:Buffer containing the zip of the code repository
Kwargs:
quiet=False (bool):
 If True, no messages are printed

Unpack script

This module contains a helper function to unpack a zip file created by the base_sys_script into the right location and format

platform_migrator.unpack.unpack(packed_zip)[source]

Unpack a zip file prepared by base_sys_script

This function unpacks the zip file, removes the env.yml and min-deps.json files from it and repacks the remaining files back as pkg.zip for use with the migrator

Args:
packed_zip (str):
 Absolute path to the zip file