Skip to content
package

rsconnect

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.</>
module

rsconnect.models

Data models

Classes
  • AppMode Data class defining an "app mode" as understood by RStudio Connect</>
  • AppModes Enumeration-like collection of known AppModes with lookup functions</>
  • GlobMatcher A simplified means of matching a path against a glob pattern. The key limitation is that we support at most one occurrence of the ** pattern.</>
  • GlobSet Matches against a set of GlobMatcher patterns</>
module

rsconnect.environment

Environment data class abstraction that is usable as an executable module

python -m rsconnect.environment
Classes
  • Environment Environment(conda, contents, error, filename, locale, package_manager, pip, python, source)</>
  • EnvironmentException Common base class for all non-exit exceptions.</>
Functions
  • conda_env_export(conda) Inspect the environment using conda env export :param: conda path to the conda tool :return: dictionary containing the key "environment.yml" and the data inside</>
  • detect_environment(dirname, force_generate, conda_mode, conda) Determine the python dependencies in the environment.</>
  • get_conda(conda) get_conda tries to find the conda executable if we're in a conda environment. If not, or if we cannot find the executable, return None. :returns: conda string path to conda or None.</>
  • main() Run detect_environment and dump the result as JSON.</>
  • output_file(dirname, filename, package_manager) Read an existing package spec file.</>
  • pip_freeze() Inspect the environment using pip freeze.</>
module

rsconnect.api

RStudio Connect API client and utility functions

Classes
  • RSConnectException Common base class for all non-exit exceptions.</>
  • RSConnectServer A simple class to encapsulate the information needed to interact with an instance of the Connect server.</>
  • RSConnect This class provides the means to simply and directly invoke HTTP requests against a server.</>
Functions
  • do_bundle_deploy(connect_server, app_id, name, title, title_is_default, bundle) Deploys the specified bundle.</>
  • emit_task_log(connect_server, app_id, task_id, log_callback, timeout) Helper for spooling the deployment log for an app.</>
  • find_unique_name(connect_server, name) Poll through existing apps to see if anything with a similar name exists. If so, start appending numbers until a unique name is found.</>
  • get_app_config(connect_server, app_id) Return the configuration information for an application that has been created in Connect.</>
  • get_app_info(connect_server, app_id) Return information about an application that has been created in Connect.</>
  • get_python_info(connect_server) Return information about versions of Python that are installed on the indicated Connect server.</>
  • override_title_search(connect_server, app_id, app_title) Returns a list of abbreviated app data that contains apps with a title that matches the given one and/or the specific app noted by its ID.</>
  • retrieve_matching_apps(connect_server, filters, limit, mapping_function) Retrieves all the app names that start with the given default name. The main point for this function is that it handles all the necessary paging logic.</>
  • verify_api_key(connect_server) Verify that an API Key may be used to authenticate with the given RStudio Connect server. If the API key verifies, we return the username of the associated user.</>
  • verify_server(connect_server) Verify that the given server information represents a Connect instance that is reachable, active and appears to be actually running RStudio Connect. If the check is successful, the server settings for the Connect server is returned.</>
module

rsconnect.actions

Public API for managing settings and deploying content.

Functions
  • are_apis_supported_on_server(connect_details) Returns whether or not the Connect server has Python itself enabled and its license allows for API usage. This controls whether APIs may be deployed..</>
  • check_server_capabilities(connect_server, capability_functions, details_source) Uses a sequence of functions that check for capabilities in a Connect server. The server settings data is retrieved by the gather_server_details() function.</>
  • cli_feedback(label) Context manager for OK/ERROR feedback from the CLI.</>
  • create_api_deployment_bundle(directory, extra_files, excludes, entry_point, app_mode, environment, extra_files_need_validating) Create an in-memory bundle, ready to deploy.</>
  • create_api_manifest_and_environment_file(directory, entry_point, environment, app_mode, extra_files, excludes, force) Creates and writes a manifest.json file for the given Python API entry point. If the related environment file (requirements.txt, environment.yml, etc.) doesn't exist (or force is set to True), the environment file will also be written.</>
  • create_notebook_deployment_bundle(file_name, extra_files, app_mode, python, environment, extra_files_need_validating, hide_all_input, hide_tagged_input) Create an in-memory bundle, ready to deploy.</>
  • create_notebook_manifest_and_environment_file(entry_point_file, environment, app_mode, extra_files, force, hide_all_input, hide_tagged_input) Creates and writes a manifest.json file for the given notebook entry point file. If the related environment file (requirements.txt, environment.yml, etc.) doesn't exist (or force is set to True), the environment file will also be written.</>
  • deploy_bokeh_app(connect_server, directory, extra_files, excludes, entry_point, new, app_id, title, python, conda_mode, force_generate, log_callback) A function to deploy a Python Bokeh app module to Connect. Depending on the files involved and network latency, this may take a bit of time.</>
  • deploy_bundle(connect_server, app_id, name, title, title_is_default, bundle) Deploys the specified bundle.</>
  • deploy_by_manifest(connect_server, manifest_file_name, new, app_id, title, log_callback) A function to deploy a Jupyter notebook to Connect. Depending on the files involved and network latency, this may take a bit of time.</>
  • deploy_dash_app(connect_server, directory, extra_files, excludes, entry_point, new, app_id, title, python, conda_mode, force_generate, log_callback) A function to deploy a Python Dash app module to Connect. Depending on the files involved and network latency, this may take a bit of time.</>
  • deploy_jupyter_notebook(connect_server, file_name, extra_files, new, app_id, title, static, python, conda_mode, force_generate, log_callback, hide_all_input, hide_tagged_input) A function to deploy a Jupyter notebook to Connect. Depending on the files involved and network latency, this may take a bit of time.</>
  • deploy_python_api(connect_server, directory, extra_files, excludes, entry_point, new, app_id, title, python, conda_mode, force_generate, log_callback) A function to deploy a Python WSGi API module to Connect. Depending on the files involved and network latency, this may take a bit of time.</>
  • deploy_python_fastapi(connect_server, directory, extra_files, excludes, entry_point, new, app_id, title, python, conda_mode, force_generate, log_callback) A function to deploy a Python ASGI API module to RStudio Connect. Depending on the files involved and network latency, this may take a bit of time.</>
  • deploy_streamlit_app(connect_server, directory, extra_files, excludes, entry_point, new, app_id, title, python, conda_mode, force_generate, log_callback) A function to deploy a Python Streamlit app module to Connect. Depending on the files involved and network latency, this may take a bit of time.</>
  • describe_manifest(file_name) Determine the entry point and/or primary file from the given manifest file. If no entry point is recorded in the manifest, then None will be returned for that. The same is true for the primary document. None will be returned for both if the file doesn't exist or doesn't look like a manifest file.</>
  • fake_module_file_from_directory(directory) Takes a directory and invents a properly named file that though possibly fake, can be used for other name/title derivation.</>
  • gather_basic_deployment_info_for_notebook(connect_server, app_store, file_name, new, app_id, title, static) Helps to gather the necessary info for performing a deployment.</>
  • gather_basic_deployment_info_from_manifest(connect_server, app_store, file_name, new, app_id, title) Helps to gather the necessary info for performing a deployment.</>
  • gather_server_details(connect_server) Builds a dictionary containing the version of RStudio Connect that is running and the versions of Python installed there.</>
  • get_python_env_info(file_name, python, conda_mode, force_generate) Gathers the python and environment information relating to the specified file with an eye to deploy it.</>
  • inspect_environment(python, directory, conda_mode, force_generate, check_output) Run the environment inspector using the specified python binary.</>
  • is_conda_supported_on_server(connect_details) Returns whether or not conda is supported on a Connect server.</>
  • set_verbosity(verbose) Set the verbosity level based on a passed flag</>
  • spool_deployment_log(connect_server, app, log_callback) Helper for spooling the deployment log for an app.</>
  • test_api_key(connect_server) Test that an API Key may be used to authenticate with the given RStudio Connect server. If the API key verifies, we return the username of the associated user.</>
  • test_server(connect_server) Test whether the given server can be reached and is running Connect. The server may be provided with or without a scheme. If a scheme is omitted, the server will be tested with both https and http until one of them works.</>
  • validate_entry_point(entry_point, directory) Validates the entry point specified by the user, expanding as necessary. If the user specifies nothing, a module of "app" is assumed. If the user specifies a module only, the object is assumed to be the same name as the module.</>
  • validate_extra_files(directory, extra_files) If the user specified a list of extra files, validate that they all exist and are beneath the given directory and, if so, return a list of them made relative to that directory.</>
  • validate_file_is_notebook(file_name) Validate that the given file is a Jupyter Notebook. If it isn't, an exception is thrown. A file must exist and have the '.ipynb' extension.</>
  • validate_manifest_file(file_or_directory) Validates that the name given represents either an existing manifest.json file or a directory that contains one. If not, an exception is raised.</>
  • which_python(python, env) Determine which python binary should be used.</>
  • write_api_manifest_json(directory, entry_point, environment, app_mode, extra_files, excludes) Creates and writes a manifest.json file for the given entry point file. If the application mode is not provided, an attempt will be made to resolve one based on the extension portion of the entry point file.</>
  • write_environment_file(environment, directory) Writes the environment file (requirements.txt, environment.yml, etc.) to the specified directory.</>
  • write_notebook_manifest_json(entry_point_file, environment, app_mode, extra_files, hide_all_input, hide_tagged_input) Creates and writes a manifest.json file for the given entry point file. If the application mode is not provided, an attempt will be made to resolve one based on the extension portion of the entry point file.</>
module

rsconnect.metadata

Metadata management objects and utility functions

Classes
  • DataStore Defines a base class for a persistent store. The store supports a primary location and an optional secondary one.</>
  • ServerStore Defines a metadata store for server information.</>
  • AppStore Defines a metadata store for information about where the app has been deployed. Each instance of this store represents one application as represented by its entry point file.</>
Functions
  • config_dirname(platform, env) Get the user's configuration directory path for this platform.</>
  • makedirs(filepath) Create the parent directories of filepath.</>
module

rsconnect.log

Logging wrapper and shared instance

Classes
  • RSLogger An adapter for loggers which makes it easier to specify contextual information in logging output.</>
module

rsconnect.http_support

HTTP support wrappers and utility functions

Classes
  • HTTPResponse This class represents the result of executing an HTTP request.</>
  • HTTPServer This class provides the means to simply and directly invoke HTTP requests against a server.</>
Functions
  • append_to_path(uri, path) This is a helper function for appending a path to a URI (i.e, just the path portion of a full URL). The main purpose is to make sure one and only one slash ends up between them.</>