Skip to main content

project

class atscale.project.project.Project

Creates an object corresponding to an AtScale project. References an AtScale Client and takes a project ID (and optionally a published project ID) to construct an object that houses DataModels, data sets, and any functionality pertaining to project maintenance.

create_data_model

Creates a new empty DataModel in the current project and sets the name to the given query_name.

  • Parameters:
    • query_name (str) – The query name for the newly created model.
    • caption (str , optional) – The caption of the model. Defaults to “” to leave the same as the query_name.
    • description (str , optional) – The description of the model. Defaults to “” to leave blank.
    • publish (bool , optional) – Whether to publish the project after creating the new model. Defaults to True.
  • Returns: The DataModel object for the new model.
  • Return type: DataModel

create_snapshot

Creates a snapshot of the current project.

  • Parameters: snapshot_name (str) – The name of the snapshot.
  • Returns: The snapshot ID.
  • Return type: str

delete

Unpublish all published projects built off this then delete this project

  • Returns: returns None if the project is empty
  • Return type: Nonetype

delete_dataset

Deletes any dataset with the given name, case-sensitive from all data models. Also deletes measures built from the dataset. If any calculated measures are defined using the deleted features, the user will be prompted yes or no to delete each one and if the response is no, the function will abort with no changes made.

  • Parameters:
    • dataset_name (str) – The dataset name which will be matched to the datasets to delete in the project json
    • publish (bool) – Defaults to True, whether the updated project should be published
    • delete_children (bool) – Defaults to None to prompt for every calculated_measure dependent on measures from the dataset. Setting this parameter to True or False simulates inputting ‘y’ or ‘n’, respectively, for all prompts.

delete_snapshot

Deletes a snapshot with the given id.

  • Parameters: snapshot_id (str) – The ID of the snapshot to be deleted.

property draft_project_id : str

Getter for the draft_project_id instance variable

  • Returns: The draft_project_id
  • Return type: str

get_connected_warehouse

Returns the warehouse id utilized in this project

  • Returns: the warehouse id
  • Return type: str

get_data_model

Returns the DataModel associated with this Project with the given name. If no name is provided and there is only one DataModel associated with this Project, then that one DataModel will be returned. However, if no name is given and there is more than one DataModel associated with this Project, then None will be returned.

  • Parameters: model_name (str , optional) – the name of the DataModel to be retrieved. Defaults to None.
  • Returns: a DataModel associated with this Project.
  • Return type: DataModel

get_data_models

Returns a list of dicts for each of the data models in the project.

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

get_published_projects

Get all published projects associated with this project. There can be multiple publications per id.

  • Parameters: include_soft_publish (bool , optional) – Whether to include soft publishes when looking for publishes. Defaults to False.
  • Returns: A list of dictionaries containing metadata about the various published projects
  • Return type: List[Dict]

get_snapshots

Returns a dictionary of the IDs of snapshots to the snapshot names. If snapshot_name is given the dictionary will be filtered to just snapshots with the given name.

  • Parameters: snapshot_name (str , optional) – The name of the snapshot for which the ID is requested.
  • Returns: a list of dictionaries with snapshot metadata
  • Return type: List[Dict]

property project_name : str

Getter for the project_name instance variable

  • Returns: The project_name
  • Return type: str

publish

Publishes the project so any changes become available to query

  • Parameters:
    • new_query_name (str , optional) – The new query name to use for the published project,
    • exists. (will use the default if None. Defaults to None. Do not use a query_name that already)
    • version_tag (str , optional) – A string to tag the published version with. Defaults to None.
  • Returns: The id of the published project
  • Return type: str

property published_project_id : str

Getter for the published_project_id instance variable

  • Returns: The published_project_id
  • Return type: str

property published_project_name : str

Getter for the published_project_name instance variable

  • Returns: The published_project_name
  • Return type: str

restore_snapshot

Restores a project to the state captured in a snapshot.

  • Parameters: snapshot_id (str) – The ID of the snapshot to be restored from.

select_data_model

Prompts the user to select a DataModel that the project can access.

  • Parameters:
    • data_model_id (str , optional) – A data model id, will select the model with the matching id. If None, asks user to select from list. Defaults to None.
    • name_contains (str , optional) – A string to use for string comparison to filter the found data model names. Defaults to None.
  • Returns: the selected DataModel
  • Return type: DataModel

select_published_project

Prompts the user for input and sets the published project on this Project instance to the selected project.

  • Parameters: include_soft_publish (bool , optional) – Whether to include soft publishes when looking for publishes. Defaults to False.

unpublish

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

update_snapshot

Updates the snapshot with the given id to have the new name.

  • Parameters:
    • snapshot_id (str) – The ID of the snapshot to update.
    • new_snapshot_name (str) – The new name for the snapshot.