Skip to main content

A sample test package

Project description

afl-ai-utils

rm -rf build dist 
python3 setup.py sdist bdist_wheel
twine upload --repository pypi dist/* 

Installation

    pip install afl-ai-utils

Usage

Slack Alerting

from afl_ai_utils.slack_alerts import send_slack_alert 
send_slack_alert(info_alert_slack_webhook_url=None, red_alert_slack_webhook_url=None, slack_red_alert_userids=None, payload=None, is_red_alert=False)

    """Send a Slack message to a channel via a webhook.

Args:
    info_alert_slack_webhook_url(str): Infor slack channel url
    red_alert_slack_webhook_url(str): red alert channel url
    slack_red_alert_userids (list): userid's to mention in slack for red alert notification
    payload (dict): Dictionary containing Slack message, i.e. {"text": "This is a test"}
    is_red_alert (bool): Full Slack webhook URL for your chosen channel.

Returns:
    HTTP response code, i.e. <Response [503]>
"""

BigQuery Dataframe to BigQuery and get result in Datafeame

    def dump_dataframe_to_bq_table(self, dataframe: pd.DataFrame, schema_cols_type: dict, table_id: str, mode: str):

    >>> from afl_ai_utils.bigquery_utils import BigQuery
    >>> bq = BigQuery("keys.json")
    >>> bq.write_insights_to_bq_table(dataframe=None, schema=None, table_id=None, mode=None)
    
    
    """Insert a dataframe to bigquery

    Args:
        dataframe(pandas dataframe): for dataframe to be dumped to bigquery
        schema(BigQuery.Schema ): ex:
        schema_cols_type: {"date_start":"date", "id": "integer", "name": "string"}
        table_id (list): table_id in which dataframe need to be inserted e.g project_id.dataset.table_name = table_id
        mode(str): To append or replace the table - e.g mode = "append"  or mode="replace"
    Returns:
        returns as success message with number of inserted rows and table name
    """

Execute any query to BigQuery

    def execute_query(self, query):

    >>> from afl_ai_utils.bigquery_utils import BigQuery
    >>> bq = BigQuery("keys.json")
    >>> df = bq.execute_query(query = "SELECT * FROM TABLE")
    
    
    """
    Args:
        query (query of any type SELECT/INSERT/DELETE ) 
    Returns:
        returns dataframe of execute query result
    """

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

afl-ai-utils-0.4.6.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

afl_ai_utils-0.4.6-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file afl-ai-utils-0.4.6.tar.gz.

File metadata

  • Download URL: afl-ai-utils-0.4.6.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for afl-ai-utils-0.4.6.tar.gz
Algorithm Hash digest
SHA256 95a00f45471f190a4989dbf8896558f68d940b1edd36c4c4edc8198b48ae4706
MD5 ef5545aef1305bb3851805357f2434da
BLAKE2b-256 7737f112ee11d45ac3a90ca7d871ed40b4fcb6c473ad24f1ce8fad2ca0b22427

See more details on using hashes here.

File details

Details for the file afl_ai_utils-0.4.6-py3-none-any.whl.

File metadata

File hashes

Hashes for afl_ai_utils-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 42b21f37dd988f32bdfbb1a85d078bd411dffdcc4424d5fe9e3d9c3af1924eda
MD5 5ae3f402765d0d441b50dcc1d1c56476
BLAKE2b-256 ce1bc58defd7acceef21db79fac15f72439f7d0ce1b3f47f195ce83327f50eb0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page