Skip to main content

client

class atscale.client.client.Client

Creates a Client with a connection to an AtScale server to allow for interaction with the projects on the server.

autogen_semantic_model

Auto-generates a project and semantic layer based on column types and values. If a dataframe is provided it will be uploaded to create the table. If dataframe is None we will try to use an already existing table with the given table_name.

  • Parameters:
    • dbconn (SQLConnection) – the database to store our new table
    • warehouse_id (str) – the name of the database connection in AtScale
    • project_name (str) – name of the new project to create
    • table_name (str) – name of the table in the source database
    • dataframe (DataFrame , optional) – the pandas dataframe to build our semantic model from. Defaults to none to use an existing table
    • generate_date_table (bool , optional) – whether generate a date table in the data warehouse. Defaults to True.
    • default_aggregation_type (Aggs) – the default aggregation type for numeric columns. Defaults to SUM
    • publish (bool , optional) – whether created project should be published. Defaults to True.
    • check_permissions (bool , optional) – Whether to error if the atscale warehouse connection does not have select/read permissions on the table. Defaults to True.
  • Returns: the newly created Project object
  • Return type: Project

clone_project

Clones the given project.

  • Parameters:
    • base_project (Project) – The base project to clone.
    • clone_name (str) – The query name of the new cloned project.
    • publish (bool) – Defaults to True, whether the new project should be published
  • Returns: The clone of the current project
  • Return type: Project

connect

Initializes the Client object’s connection

create_empty_project

Creates an empty project in the associated org

  • Parameters: project_name (str) – The name of the empty project to be created
  • Returns: An empty project
  • Return type: Project

get_connected_databases

Get a list of databases the organization can access in the provided warehouse.

  • Parameters: warehouse_id (str) – The AtScale warehouse connection to use.
  • Returns: The list of available databases
  • Return type: List[str]

get_connected_schemas

Get a list of schemas the organization can access in the provided warehouse and database.

  • Parameters:
    • warehouse_id (str) – The AtScale warehouse connection to use.
    • database (str) – The database to use.
  • Returns: The list of available tables
  • Return type: List[str]

get_connected_tables

Get a list of tables the organization can access in the provided warehouse, database, and schema.

  • Parameters:
    • warehouse_id (str) – The AtScale warehouse connection to use.
    • database (str) – The database to use.
    • schema (str) – The schema to use.
  • Returns: The list of available tables
  • Return type: List[str]

get_connected_warehouses

Returns metadata on all warehouses visible to the connected client

  • Returns: The list of available warehouses
  • Return type: List[Dict]

get_organizations

Prints all Organizations for the associated Server if possible and returns a list of dicts : for each of the listed organizations. List index should match printed index.

  • Returns: List of ‘id’:’name’ pairs of available orgs.
  • Return type: List[Dict[str,str]]

get_projects

Returns a list of dicts for each of the listed Projects.

  • Parameters: include_soft_publish (bool , optional) – Whether to include soft published projects. Defaults to False.
  • Returns: List of 3 item dicts where keys are ‘draft_id’, ‘draft_name’, ‘published_projects’ of available Projects.
  • Return type: List[Dict[str,str]]

get_published_projects

Prints all Published Projects that are visible for the associated organization for the : given draft project id. Returns a list of dicts for each of the listed Projects. List index should match printed index.

  • Parameters:
    • draft_project_id (str) – The id of the draft project of interest
    • include_soft_publish (bool , optional) – Whether to include soft published projects. Defaults to False.
  • Returns: List of ‘id’:’name’ pairs of available published Projects.
  • Return type: List[Dict[str,str]]

get_query_columns

Get all columns of a direct query, to the given warehouse_id, as they are represented by AtScale.

  • Parameters:
    • warehouse_id (str) – The AtScale warehouse to use.
    • query (str) – A valid query for the warehouse of the given id, of which to return the resulting columns
  • Returns: A list of columns represented as Tuples of (name, data-type)
  • Return type: List[Tuple]

get_table_columns

Get all columns in a given table

  • Parameters:
    • warehouse_id (str) – The AtScale warehouse to use.
    • table_name (str) – The name of the table to use.
    • database (str , optional) – The database to use. Defaults to None to use default database
    • schema (str , optional) – The schema to use. Defaults to None to use default schema
    • expected_columns (List *[*str ] , optional) – A list of expected column names to validate. Defaults to None
  • Returns: Pairs of the columns and data-types (respectively) of the passed table
  • Return type: List[Tuple]

get_version

A getter function for the current version of the library

  • Returns: The current version of the library
  • Return type: str

select_project

Selects a project based on user input

  • Parameters:
    • draft_project_id (str , optional) – An draft project id, will result in a prompt to select a published project if one exists. If None, asks user to select from list of draft projects. Defaults to None.
    • published_project_id (str , optional) – The published project id to use if multiple exist for the given draft. If None, user will be prompted to select a published project if one exists. Defaults to None.
    • name_contains (str , optional) – A string to use for string comparison to filter the found project names. If None, no filter will be applied. Defaults to None.
    • include_soft_publish (bool , optional) – Whether to include soft published projects. Defaults to False.
  • Returns: The desired project
  • Return type: Project

unpublish_project

Unpublishes the provided published_project_id making in no longer queryable

  • Parameters: published_project_id (str) – the id of the published project to unpublish
  • Returns: Whether the unpublish was successful
  • Return type: bool