chai_py.packaging module¶
-
class
chai_py.packaging.
Metadata
(name: str, image_url: str, color: str, description: str, input_class: Type[chai_py.chai_bot.ChaiBot], developer_uid: str = <factory>, memory: int = 256)¶ Bases:
object
Information required for bot deployment.
-
color
: str¶
-
description
: str¶
-
developer_uid
: str¶
-
image_url
: str¶
-
input_class
: Type[chai_py.chai_bot.ChaiBot]¶
-
memory
: int = 256¶
-
name
: str¶
-
verify
(bot_file: pathlib.Path)¶ Performs basic checks to ensure validity of the metadata.
-
-
chai_py.packaging.
copytree
(src, dst, symlinks=False, ignore=None)¶ Copies files from src to dst.
Taken from https://stackoverflow.com/a/22331852. Necessitated by Python 3.7 environment; Python 3.8’s shutil.copytree can be used directly as it has the necessary dirs_exist_ok argument.
- Parameters
src – Source directory
dst – Target directory
symlinks –
ignore – Callable
- Returns
-
chai_py.packaging.
package
(metadata: chai_py.packaging.Metadata, requirements: Optional[List[str]] = None, path: Optional[str] = None)¶ Packages the chatbot into a single archive for deployment.
Performs some preliminary checks on the metadata. Creates a _package.zip file in the directory containing the file that contains the bot class unless a path is provided.
- Parameters
metadata –
requirements –
path –
- Returns
-
chai_py.packaging.
verify_image_url
(url: str)¶ Verifies that the provided url resolves to an image.
Performs a GET request on the given url and performs a trivial (non-conclusive) check that the image type can be inferred from the received bytes.
- Parameters
url –
- Returns
-
chai_py.packaging.
write_valid_requirements_file
(path: AnyStr, requirements: List[str])¶ Writes a valid requirements.txt file.
Iterates through list of requirements, writing valid entries to the specified file, Ignores (and prints) invalid requirements.
- Parameters
path –
requirements –
- Returns
-
chai_py.packaging.
zipfile_from_folder
(folder: AnyStr, file)¶