text
stringlengths
81
112k
Return the name of the default bucket to use in relevant Amazon SageMaker interactions. Returns: str: The name of the default bucket, which is of the form: ``sagemaker-{region}-{AWS account ID}``. def default_bucket(self): """Return the name of the default bucket to use in relevant Amazon ...
Create an Amazon SageMaker training job. Args: input_mode (str): The input mode that the algorithm supports. Valid modes: * 'File' - Amazon SageMaker copies the training dataset from the S3 location to a directory in the Docker container. * 'Pipe...
Create an Amazon SageMaker Neo compilation job. Args: input_model_config (dict): the trained model and the Amazon S3 location where it is stored. output_model_config (dict): Identifies the Amazon S3 location where you want Amazon SageMaker Neo to save the results of comp...
Create an Amazon SageMaker hyperparameter tuning job Args: job_name (str): Name of the tuning job being created. strategy (str): Strategy to be used for hyperparameter estimations. objective_type (str): The type of the objective metric for evaluating training jobs. This valu...
Stop the Amazon SageMaker hyperparameter tuning job with the specified name. Args: name (str): Name of the Amazon SageMaker hyperparameter tuning job. Raises: ClientError: If an error occurs while trying to stop the hyperparameter tuning job. def stop_tuning_job(self, name): ...
Create an Amazon SageMaker transform job. Args: job_name (str): Name of the transform job being created. model_name (str): Name of the SageMaker model being used for the transform job. strategy (str): The strategy used to decide how to batch records in a single request. ...
Create an Amazon SageMaker ``Model``. Specify the S3 location of the model artifacts and Docker image containing the inference code. Amazon SageMaker uses this information to deploy the model in Amazon SageMaker. This method can also be used to create a Model for an Inference Pipeline if...
Create an Amazon SageMaker ``Model`` from a SageMaker Training Job. Args: training_job_name (str): The Amazon SageMaker Training Job name. name (str): The name of the SageMaker ``Model`` to create (default: None). If not specified, the training job name is used. ...
Create a SageMaker Model Package from the results of training with an Algorithm Package Args: name (str): ModelPackage name description (str): Model Package description algorithm_arn (str): arn or name of the algorithm used for training. model_data (str): s3 URI ...
Wait for an Amazon SageMaker endpoint deployment to complete. Args: endpoint (str): Name of the ``Endpoint`` to wait for. poll (int): Polling interval in seconds (default: 5). Returns: dict: Return value from the ``DescribeEndpoint`` API. def wait_for_model_package...
Create an Amazon SageMaker endpoint configuration. The endpoint configuration identifies the Amazon SageMaker model (created using the ``CreateModel`` API) and the hardware configuration on which to deploy the model. Provide this endpoint configuration to the ``CreateEndpoint`` API, which then ...
Create an Amazon SageMaker ``Endpoint`` according to the endpoint configuration specified in the request. Once the ``Endpoint`` is created, client applications can send requests to obtain inferences. The endpoint configuration is created using the ``CreateEndpointConfig`` API. Args: ...
Update an Amazon SageMaker ``Endpoint`` according to the endpoint configuration specified in the request Raise an error if endpoint with endpoint_name does not exist. Args: endpoint_name (str): Name of the Amazon SageMaker ``Endpoint`` to update. endpoint_config_name (str): Nam...
Delete an Amazon SageMaker ``Endpoint``. Args: endpoint_name (str): Name of the Amazon SageMaker ``Endpoint`` to delete. def delete_endpoint(self, endpoint_name): """Delete an Amazon SageMaker ``Endpoint``. Args: endpoint_name (str): Name of the Amazon SageMaker ``Endp...
Delete an Amazon SageMaker endpoint configuration. Args: endpoint_config_name (str): Name of the Amazon SageMaker endpoint configuration to delete. def delete_endpoint_config(self, endpoint_config_name): """Delete an Amazon SageMaker endpoint configuration. Args: endpo...
Delete an Amazon SageMaker Model. Args: model_name (str): Name of the Amazon SageMaker model to delete. def delete_model(self, model_name): """Delete an Amazon SageMaker Model. Args: model_name (str): Name of the Amazon SageMaker model to delete. """ L...
Wait for an Amazon SageMaker training job to complete. Args: job (str): Name of the training job to wait for. poll (int): Polling interval in seconds (default: 5). Returns: (dict): Return value from the ``DescribeTrainingJob`` API. Raises: Value...
Wait for an Amazon SageMaker Neo compilation job to complete. Args: job (str): Name of the compilation job to wait for. poll (int): Polling interval in seconds (default: 5). Returns: (dict): Return value from the ``DescribeCompilationJob`` API. Raises: ...
Wait for an Amazon SageMaker hyperparameter tuning job to complete. Args: job (str): Name of the tuning job to wait for. poll (int): Polling interval in seconds (default: 5). Returns: (dict): Return value from the ``DescribeHyperParameterTuningJob`` API. Ra...
Wait for an Amazon SageMaker transform job to complete. Args: job (str): Name of the transform job to wait for. poll (int): Polling interval in seconds (default: 5). Returns: (dict): Return value from the ``DescribeTransformJob`` API. Raises: Va...
Check to see if the job completed successfully and, if not, construct and raise a ValueError. Args: job (str): The name of the job to check. desc (dict[str, str]): The result of ``describe_training_job()``. status_key_name (str): Status key name to check for. ...
Wait for an Amazon SageMaker endpoint deployment to complete. Args: endpoint (str): Name of the ``Endpoint`` to wait for. poll (int): Polling interval in seconds (default: 5). Returns: dict: Return value from the ``DescribeEndpoint`` API. def wait_for_endpoint(self...
Create an ``Endpoint`` using the results of a successful training job. Specify the job name, Docker image containing the inference code, and hardware configuration to deploy the model. Internally the API, creates an Amazon SageMaker model (that describes the model artifacts and the Docker image...
Create and deploy to an ``Endpoint`` using existing model data stored in S3. Args: model_s3_location (str): S3 URI of the model artifacts to use for the endpoint. deployment_image (str): The Docker image which defines the runtime code to be used as the entry point for ac...
Create an SageMaker ``Endpoint`` from a list of production variants. Args: name (str): The name of the ``Endpoint`` to create. production_variants (list[dict[str, str]]): The list of production variants to deploy. tags (list[dict[str, str]]): A list of key-value pairs for ta...
Expand an IAM role name into an ARN. If the role is already in the form of an ARN, then the role is simply returned. Otherwise we retrieve the full ARN and return it. Args: role (str): An AWS IAM role (either name or full ARN). Returns: str: The corresponding A...
Returns the ARN user or role whose credentials are used to call the API. Returns: (str): The ARN user or role def get_caller_identity_arn(self): """Returns the ARN user or role whose credentials are used to call the API. Returns: (str): The ARN user or role """ ...
Display the logs for a given training job, optionally tailing them until the job is complete. If the output is a tty or a Jupyter cell, it will be color-coded based on which instance the log entry is from. Args: job_name (str): Name of the training job to display the logs for. ...
Return docker registry for the given AWS region for the given framework. This is only used for SparkML and Scikit-learn for now. def registry(region_name, framework=None): """ Return docker registry for the given AWS region for the given framework. This is only used for SparkML and Scikit-learn for now...
Return a :class:`~sagemaker.amazon.KNNModel` referencing the latest s3 model data produced by this Estimator. Args: vpc_config_override (dict[str, list[str]]): Optional override for VpcConfig set on the model. Default: use subnets and security groups from this Estimator. ...
Create all the intermediate directories required for relative_path to exist within destination_directory. This assumes that relative_path is a directory located within root_dir. Examples: destination_directory: /tmp/destination relative_path: test/unit/ will create: /tmp/destination/t...
move source to destination. Can handle uploading to S3 Args: source (str): root directory to move destination (str): file:// or s3:// URI that source will be moved to. job_name (str): SageMaker job name. sagemaker_session (sagemaker.Session): a sagemaker_session to interact with S3 ...
A wrapper around distutils.dir_util.copy_tree but won't throw any exception when the source directory does not exist. Args: source (str): source path destination (str): destination path def recursive_copy(source, destination): """A wrapper around distutils.dir_util.copy_tree but won't thro...
Convert the job description to init params that can be handled by the class constructor Args: job_details: the returned job details from a describe_training_job API call. model_channel_name (str): Name of the channel where pre-trained model data will be downloaded. Returns: ...
Start a new transform job. Args: data (str): Input data location in S3. data_type (str): What the S3 location defines (default: 'S3Prefix'). Valid values: * 'S3Prefix' - the S3 URI defines a key name prefix. All objects with this prefix will be used as ...
Attach an existing transform job to a new Transformer instance Args: transform_job_name (str): Name for the transform job to be attached. sagemaker_session (sagemaker.session.Session): Session object which manages interactions with Amazon SageMaker APIs and any other AWS...
Convert the transform job description to init params that can be handled by the class constructor Args: job_details (dict): the returned job details from a describe_transform_job API call. Returns: dict: The transformed init_params def _prepare_init_params_from_job_description...
Returns the piece size (vocabulary size). Args: model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argument that is passed to the op function. Returns: A scalar repre...
Converts piece into vocabulary id. Args: input: An arbitrary tensor of string. model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argument that is passed to the op func...
Converts vocabulary id into piece. Args: input: An arbitrary tensor of int32. model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argument that is passed to the op funct...
Returns true if input id is unknown piece. Args: input: An arbitrary tensor of int32. model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argument that is passed to the ...
Returns true if input id is control piece. Args: input: An arbitrary tensor of int32. model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argument that is passed to the ...
Returns true if input id is unused piece. Args: input: An arbitrary tensor of int32. model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argument that is passed to the o...
Encodes sentences into pieces in dense tensor format. Args: input_sentences: A 1D string tensor of arbitrary size holding the raw text of input sentences. nbest_size: A scalar or 1D tensor for sampling. nbest_size = {0,1}: No sampling is performed. nbest_s...
Encodes sentences into pieces in sparse tensor format. Args: input_sentences: A 1D string tensor of arbitrary size holding the raw text of input sentences. nbest_size: A scalar or 1D tensor for sampling. nbest_size = {0,1}: No sampling is performed. nbest_...
Decode pieces into postprocessed text. Args: pieces: A 2D int32 or string tensor [batch_size x max_length] of encoded sequences. sequence_length: A 1D int32 tensor [batch_size] representing the length of pieces. model_file: The sentencepiece model file path. model_proto...
Splits one string into multiple strings, with a maximum amount of `chars_per_string` characters per string. This is very useful for splitting one giant message into multiples. :param text: The text to split :param chars_per_string: The number of characters per line the text is split into. :return: The ...
Returns the argument after the command. Examples: extract_arguments("/get name"): 'name' extract_arguments("/get"): '' extract_arguments("/get@botName name"): 'name' :param text: String to extract the arguments from a command :return: the arguments if `text` is a command (according to ...
When new messages arrive TeleBot will call this function. def listener(messages): """ When new messages arrive TeleBot will call this function. """ for m in messages: if m.content_type == 'text': # print the sent message to the console print(str(m.chat.first_name) + " ["...
Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is. If it is not, it is converted to a dict by means of json.loads(json_type) :param json_type: :return: def check_json(json_type): """ Checks whether json_type is a dict or a string. If i...
Author: @sviat9440 Message: "*Test* parse _formatting_, [url](https://example.com), [text_mention](tg://user?id=123456) and mention @username" Example: message.html_text >> "<b>Test</b> parse <i>formatting</i>, <a href=\"https://example.com\">url</a>, <a href=\"tg://user?id=1234...
This function adds strings to the keyboard, while not exceeding row_width. E.g. ReplyKeyboardMarkup#add("A", "B", "C") yields the json result {keyboard: [["A"], ["B"], ["C"]]} when row_width is set to 1. When row_width is set to 2, the following is the result of this function: {keyboard: [["A", ...
Converts this object to its json representation following the Telegram API guidelines described here: https://core.telegram.org/bots/api#replykeyboardmarkup :return: def to_json(self): """ Converts this object to its json representation following the Telegram API guidelines described he...
This function adds strings to the keyboard, while not exceeding row_width. E.g. ReplyKeyboardMarkup#add("A", "B", "C") yields the json result {keyboard: [["A"], ["B"], ["C"]]} when row_width is set to 1. When row_width is set to 2, the following is the result of this function: {keyboard: [["A", ...
Adds a list of KeyboardButton to the keyboard. This function does not consider row_width. ReplyKeyboardMarkup#row("A")#row("B", "C")#to_json() outputs '{keyboard: [["A"], ["B", "C"]]}' See https://core.telegram.org/bots/api#inlinekeyboardmarkup :param args: strings :return: self, to allo...
Makes a request to the Telegram API. :param token: The bot's API token. (Created with @BotFather) :param method_name: Name of the API method to be called. (E.g. 'getUpdates') :param method: HTTP method to be used. Defaults to 'get'. :param params: Optional parameters. Should be a dictionary with key-val...
Checks whether `result` is a valid API response. A result is considered invalid if: - The server returned an HTTP response code other than 200 - The content of the result is invalid JSON. - The method call was unsuccessful (The JSON 'ok' field equals False) :raises ApiException: if one ...
Use this method to send text messages. On success, the sent Message is returned. :param token: :param chat_id: :param text: :param disable_web_page_preview: :param reply_to_message_id: :param reply_markup: :param parse_mode: :param disable_notification: :return: def send_message(tok...
Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat. :param token: Bot's token (you don't need to fill this) ...
Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects. This method will currently return scores for the target user, plus two of his closest neighbors on each side. Will also return...
Use this method to send invoices. On success, the sent Message is returned. :param token: Bot's token (you don't need to fill this) :param chat_id: Unique identifier for the target private chat :param title: Product name :param description: Product description :param invoice_payload: Bot-defined inv...
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. :param token: Bot's token (you don't need to fill this) :param shi...
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the...
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. Alternatively, the user can be redirected to the specified Game URL. For this option to work, you mus...
Enable saving next step handlers (by default saving disable) :param delay: Delay between changes in handlers and saving :param filename: Filename of save file def enable_save_next_step_handlers(self, delay=120, filename="./.handler-saves/step.save"): """ Enable saving next step handler...
Enable saving reply handlers (by default saving disable) :param delay: Delay between changes in handlers and saving :param filename: Filename of save file def enable_save_reply_handlers(self, delay=120, filename="./.handler-saves/reply.save"): """ Enable saving reply handlers (by defau...
Load next step handlers from save file :param filename: Filename of the file where handlers was saved :param del_file_after_loading: Is passed True, after loading save file will be deleted def load_next_step_handlers(self, filename="./.handler-saves/step.save", del_file_after_loading=True): ""...
Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned. :param allowed_updates: Array of string. List the types of updates you want your bot to receive. :param offset: Integer. Identifier of the first update to be returned. :param limit: Int...
Get and discard all pending updates before first poll of the bot :return: total updates skipped def __skip_updates(self): """ Get and discard all pending updates before first poll of the bot :return: total updates skipped """ total = 0 updates = self.get_updates(...
Retrieves any updates from the Telegram API. Registered listeners and applicable message handlers will be notified when a new message arrives. :raises ApiException when a call has failed. def __retrieve_updates(self, timeout=20): """ Retrieves any updates from the Telegram API. ...
This function creates a new Thread that calls an internal __retrieve_updates function. This allows the bot to retrieve Updates automagically and notify listeners and message handlers accordingly. Warning: Do not call this function more than once! Always get updates. :param interval: ...
Retrieves the user profile photos of the person with 'user_id' See https://core.telegram.org/bots/api#getuserprofilephotos :param user_id: :param offset: :param limit: :return: API reply. def get_user_profile_photos(self, user_id, offset=None, limit=None): """ Re...
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. :param chat_id: :return: def get_chat(self, chat_id): """ Use this method t...
Use this method for your bot to leave a group, supergroup or channel. Returns True on success. :param chat_id: :return: def leave_chat(self, chat_id): """ Use this method for your bot to leave a group, supergroup or channel. Returns True on success. :param chat_id: :retu...
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. :param chat_id: :return: def get_chat_administrators(self, chat_id): """ Use this method to ge...
Use this method to get the number of members in a chat. Returns Int on success. :param chat_id: :return: def get_chat_members_count(self, chat_id): """ Use this method to get the number of members in a chat. Returns Int on success. :param chat_id: :return: """ ...
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns Tr...
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on su...
Use this method to get information about a member of a chat. Returns a ChatMember object on success. :param chat_id: :param user_id: :return: def get_chat_member(self, chat_id, user_id): """ Use this method to get information about a member of a chat. Returns a ChatMember object...
Use this method to send text messages. Warning: Do not send more than about 5000 characters each message, otherwise you'll risk an HTTP 414 error. If you must send more than 5000 characters, use the split_string function in apihelper.py. :param chat_id: :param text: :param disa...
Use this method to forward messages of any kind. :param disable_notification: :param chat_id: which chat to forward :param from_chat_id: which chat message from :param message_id: message id :return: API reply. def forward_message(self, chat_id, from_chat_id, message_id, disable...
Use this method to delete message. Returns True on success. :param chat_id: in which chat to delete :param message_id: which message to delete :return: API reply. def delete_message(self, chat_id, message_id): """ Use this method to delete message. Returns True on success. ...
Use this method to send photos. :param disable_notification: :param chat_id: :param photo: :param caption: :param parse_mode :param reply_to_message_id: :param reply_markup: :return: API reply. def send_photo(self, chat_id, photo, caption=None, reply_to_m...
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. :param chat_id:Unique identifier for the message recipient :param audio:Audio file to send. :param duration:Duration of the audio in seconds :para...
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. :param chat_id:Unique identifier for the message recipient. :param voice: :param duration:Duration of sent audio in seconds :param reply_to_message_id: :param reply_...
Use this method to send general files. :param chat_id: :param data: :param reply_to_message_id: :param reply_markup: :param parse_mode: :param disable_notification: :return: API reply. def send_document(self, chat_id, data, reply_to_message_id=None, caption=None,...
Use this method to send .webp stickers. :param chat_id: :param data: :param reply_to_message_id: :param reply_markup: :return: API reply. def send_sticker(self, chat_id, data, reply_to_message_id=None, reply_markup=None, disable_notification=None, timeout=No...
Use this method to send video files, Telegram clients support mp4 videos. :param chat_id: Integer : Unique identifier for the message recipient — User or GroupChat id :param data: InputFile or String : Video to send. You can either pass a file_id as String to resend a video that is already on the Telegr...
Use this method to send video files, Telegram clients support mp4 videos. :param chat_id: Integer : Unique identifier for the message recipient — User or GroupChat id :param data: InputFile or String : Video note to send. You can either pass a file_id as String to resend a video that is already on the T...
send a group of photos or videos as an album. On success, an array of the sent Messages is returned. :param chat_id: :param media: :param disable_notification: :param reply_to_message_id: :return: def send_media_group(self, chat_id, media, disable_notification=None, reply_to_mes...
Use this method to send point on the map. :param chat_id: :param latitude: :param longitude: :param live_period :param reply_to_message_id: :param reply_markup: :return: API reply. def send_location(self, chat_id, latitude, longitude, live_period=None, reply_to_m...
Use this method to edit live location :param latitude: :param longitude: :param chat_id: :param message_id: :param inline_message_id: :param reply_markup: :return: def edit_message_live_location(self, latitude, longitude, chat_id=None, message_id=None, ...
Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires :param chat_id: :param message_id: :param inline_message_id: :param reply_markup: :return: def stop_message_live_location(self, chat_id=No...
Use this method to send information about a venue. :param chat_id: Integer or String : Unique identifier for the target chat or username of the target channel :param latitude: Float : Latitude of the venue :param longitude: Float : Longitude of the venue :param title: String : Name of th...
Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). :param chat_id: :param action: One of the following strings: 'typing', ...
Use this method to kick a user from a group or a supergroup. :param chat_id: Int or string : Unique identifier for the target group or username of the target supergroup :param user_id: Int : Unique identifier of the target user :param until_date: Date when the user will be unbanned, unix time. I...
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success. :param chat_id: Int or Strin...
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success. :param chat_id: Unique identifier f...
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. Note: In regular groups (non-supergroups), this method will only ...
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. Note: In regular groups (non-supergroups), this method will only work if th...