Skip to content
module

rsconnect.bundle

Manifest generation and bundling utilities

Functions
  • buffer_checksum(buf) Calculate the md5 hex digest of a buffer (str or bytes)</>
  • bundle_add_buffer(bundle, filename, contents) Add an in-memory buffer to the tarball.</>
  • bundle_add_file(bundle, rel_path, base_dir) Add the specified file to the tarball.</>
  • create_glob_set(directory, excludes) Takes a list of glob strings and produces a GlobSet for path matching.</>
  • file_checksum(path) Calculate the md5 hex digest of the specified file</>
  • keep_manifest_specified_file(relative_path) A helper to see if the relative path given, which is assumed to have come from a manifest.json file, should be kept or ignored.</>
  • list_environment_dirs(directory) Returns a list of subdirectories in directory that appear to contain virtual environments.</>
  • list_files(base_dir, include_sub_dirs, walk) List the files in the directory at path.</>
  • make_api_bundle(directory, entry_point, app_mode, environment, extra_files, excludes) Create an API bundle, given a directory path and a manifest.</>
  • make_api_manifest(directory, entry_point, app_mode, environment, extra_files, excludes) Makes a manifest for an API.</>
  • make_manifest_bundle(manifest_path) Create a bundle, given a manifest.</>
  • make_notebook_source_bundle(file, environment, extra_files, hide_all_input, hide_tagged_input) Create a bundle containing the specified notebook and python environment.</>
  • manifest_add_buffer(manifest, filename, buf) Add the specified in-memory buffer to the manifest files section</>
  • manifest_add_file(manifest, rel_path, base_dir) Add the specified file to the manifest files section</>
  • read_manifest_file(manifest_path) Read a manifest's content from its file. The content is provided as both a raw string and a parsed dictionary.</>
  • write_manifest(relative_dir, nb_name, environment, output_dir, hide_all_input, hide_tagged_input) Create a manifest for source publishing the specified notebook.</>
function

rsconnect.bundle.manifest_add_file(manifest, rel_path, base_dir)

Add the specified file to the manifest files section

The file must be specified as a pathname relative to the notebook directory.

function

rsconnect.bundle.manifest_add_buffer(manifest, filename, buf)

Add the specified in-memory buffer to the manifest files section

function

rsconnect.bundle.file_checksum(path)

Calculate the md5 hex digest of the specified file

function

rsconnect.bundle.buffer_checksum(buf)

Calculate the md5 hex digest of a buffer (str or bytes)

function

rsconnect.bundle.bundle_add_file(bundle, rel_path, base_dir)

Add the specified file to the tarball.

The file path is relative to the notebook directory.

function

rsconnect.bundle.bundle_add_buffer(bundle, filename, contents)

Add an in-memory buffer to the tarball.

contents may be a string or bytes object

function

rsconnect.bundle.write_manifest(relative_dir, nb_name, environment, output_dir, hide_all_input=False, hide_tagged_input=False)

Create a manifest for source publishing the specified notebook.

The manifest will be written to manifest.json in the output directory.. A requirements.txt file will be created if one does not exist.

Returns the list of filenames written.

function

rsconnect.bundle.list_files(base_dir, include_sub_dirs, walk=<function walk at 0x7fcd9f606f70>)

List the files in the directory at path.

If include_sub_dirs is True, recursively list files in subdirectories.

Returns an iterable of file paths relative to base_dir.

function

rsconnect.bundle.make_notebook_source_bundle(file, environment, extra_files=None, hide_all_input=False, hide_tagged_input=False)

Create a bundle containing the specified notebook and python environment.

Returns a file-like object containing the bundle tarball.

function

rsconnect.bundle.keep_manifest_specified_file(relative_path)

A helper to see if the relative path given, which is assumed to have come from a manifest.json file, should be kept or ignored.

:param relative_path: the relative path name to check. :return: True, if the path should kept or False, if it should be ignored.

function

rsconnect.bundle.read_manifest_file(manifest_path)

Read a manifest's content from its file. The content is provided as both a raw string and a parsed dictionary.

:param manifest_path: the path to the file to read. :return: the parsed manifest data and the raw file content as a string.

function

rsconnect.bundle.make_manifest_bundle(manifest_path)

Create a bundle, given a manifest.

:return: a file-like object containing the bundle tarball.

function

rsconnect.bundle.create_glob_set(directory, excludes)

Takes a list of glob strings and produces a GlobSet for path matching.

Note: we don't use Python's glob support because it takes way too long to run when large file trees are involved in conjunction with the '**' pattern.

:param directory: the directory the globs are relative to. :param excludes: the list of globs to expand. :return: a GlobSet ready for path matching.

function

rsconnect.bundle.list_environment_dirs(directory)

Returns a list of subdirectories in directory that appear to contain virtual environments.

function

rsconnect.bundle.make_api_manifest(directory, entry_point, app_mode, environment, extra_files=None, excludes=None)

Makes a manifest for an API.

:param directory: the directory containing the files to deploy. :param entry_point: the main entry point for the API. :param app_mode: the app mode to use. :param environment: the Python environment information. :param extra_files: a sequence of any extra files to include in the bundle. :param excludes: a sequence of glob patterns that will exclude matched files. :return: the manifest and a list of the files involved.

function

rsconnect.bundle.make_api_bundle(directory, entry_point, app_mode, environment, extra_files=None, excludes=None)

Create an API bundle, given a directory path and a manifest.

:param directory: the directory containing the files to deploy. :param entry_point: the main entry point for the API. :param app_mode: the app mode to use. :param environment: the Python environment information. :param extra_files: a sequence of any extra files to include in the bundle. :param excludes: a sequence of glob patterns that will exclude matched files. :return: a file-like object containing the bundle tarball.