Module lunar.data

Sub-modules

lunar.data.batch
lunar.data.data
lunar.data.datasets
lunar.data.query

Classes

class BatchClient (config: Config)

Client for BAP Data API (/v1/batch).

Example

import bap

client = bap.client("batch")

Ancestors

Methods

def get_batch_list(self, job_status_list: List[str]) ‑> List[Dict[str, Any]]

Get a list of batch jobs.

Args

  • job_status_list: (list) List of job_status of Batch ('SUBMITTED' | 'PENDING' | 'RUNNABLE' | 'STARTING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED')

Returns

list

Example

data = client.get_batch_list(job_status_list=["STARTING", "RUNNING"])

async def get_batch_list_async(self, job_status_list: List[str]) ‑> List[Dict[str, Any]]

Get a list of batch jobs (async).

Args

  • job_status_list: (list) List of job_status of Batch ('SUBMITTED' | 'PENDING' | 'RUNNABLE' | 'STARTING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED')

Returns

list

Example

data = await client.get_batch_list_async(job_status_list=["STARTING", "RUNNING"])

class DataClient (config: Config)

Client for BAP Data API (/v1/data).

Example

import bap

client = bap.client("data")

Ancestors

Methods

def create_data(self, dataset_id: str, id: str, attributes: Dict[str, Any]) ‑> Dict[str, Any]

Create a data.

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (dict) Attributes to create from datasets

Returns

dict

Example

data = client.create_data(dataset_id="my_dataset", id="my_id", attributes={"f1": 1, "f2": 2})
async def create_data_async(self, dataset_id: str, id: str, attributes: Dict[str, Any]) ‑> Dict[str, Any]

Create a data (async).

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (dict) Attributes to create from datasets

Returns

dict

Example

data = await client.create_data_async(dataset_id="my_dataset", id="my_id", attributes={"f1": 1, "f2": 2})
def get_batch_data(self, dataset_id: str, ids: List[str], attributes: List[str] = None, headers: Dict[str, Any] = {}) ‑> Dict[str, Any]

Get batch data results.

Args

  • dataset_id: (str) Unique identifier of a dataset
  • ids: (list) List of unique identifiers of targets
  • attributes: (optional) (dict) Attributes to get from datasets. If not, all attributes of result would be returned
  • headers: (optional) (dict) Headers being sent to API server

Returns

dict

Example

data = client.get_batch_data(dataset_id="my_dataset", ids=["id_1", "id_2"], attributes=["f1", "f2"])
async def get_batch_data_async(self, dataset_id: str, ids: List[str], attributes: List[str] = None, headers: Dict[str, Any] = {}) ‑> Dict[str, Any]

Get batch data results (async).

Args

  • dataset_id: (str) Unique identifier of a dataset
  • ids: (list) List of unique identifiers of targets
  • attributes: (optional) (dict) Attributes to get from datasets. If not, all attributes of result would be returned
  • headers: (optional) (dict) Headers being sent to API server

Returns

dict

Example

data = await client.get_batch_data_async(dataset_id="my_dataset", ids=["id_1", "id_2"], attributes=["f1", "f2"])
def get_data(self, dataset_id: str, id: str, attributes: List[str] = None, headers: Dict[str, Any] = {}) ‑> Dict[str, Any]

Get a data result.

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (optional) (dict) Attributes to get from datasets. If not, all attributes of result would be returned
  • headers: (optional) (dict) Headers being sent to API server

Returns

dict

Example

data = client.get_data(dataset_id="my_dataset", id="my_id", attributes=["f1", "f2"])
async def get_data_async(self, dataset_id: str, id: str, attributes: List[str] = None, headers: Dict[str, Any] = {}) ‑> Dict[str, Any]

Get a data result (async).

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (optional) (dict) Attributes to get from datasets. If not, all attributes of result would be returned
  • headers: (optional) (dict) Headers being sent to API server

Returns

dict

Example

data = await client.get_data_async(dataset_id="my_dataset", id="my_id", attributes=["f1", "f2"])
def update_data(self, dataset_id: str, id: str, attributes: Dict[str, Any]) ‑> Dict[str, Any]

Update a data.

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (dict) Attributes to update from datasets

Returns

dict

Example

data = client.update_data(dataset_id="my_dataset", id="my_id", attributes={"f1": 1, "f2": 2, "f3": 3})
async def update_data_async(self, dataset_id: str, id: str, attributes: Dict[str, Any]) ‑> Dict[str, Any]

Update a data (async).

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (dict) Attributes to update from datasets

Returns

dict

Example

data = await client.update_data_async(dataset_id="my_dataset", id="my_id", attributes={"f1": 1, "f2": 2, "f3": 3})
def update_data_partial(self, dataset_id: str, id: str, attributes: Dict[str, Any]) ‑> Dict[str, Any]

Partially update a data.

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (dict) Attributes to partially update from datasets

Returns

dict

Example

data = client.update_data_partial(dataset_id="my_dataset", id="my_id", attributes={"feature": "a"})
async def update_data_partial_async(self, dataset_id: str, id: str, attributes: Dict[str, Any]) ‑> Dict[str, Any]

Partially update a data (async).

Args

  • dataset_id: (str) Unique identifier of a dataset
  • id: (str) Unique identifier of a target
  • attributes: (dict) Attributes to partially update from datasets

Returns

dict

Example

data = await client.update_data_partial_async(dataset_id="my_dataset", id="my_id", attributes={"feature": "a"})
class DatasetClient (config: Config)

Client for BAP Data API (/v1/datasets/).

Example

import bap

client = bap.client("dataset")

Ancestors

Methods

def create_dataset(self, id: str, data_type: str, params: Dict[str, Any]) ‑> Dataset

Create a new dataset.

Args

  • id: (str) Unique identifier of a dataset
  • data_type: (str) Dataset type
  • params: (dict) Dataset parameters

Returns

Dataset

Example

# For dynamodb
dataset = client.create_dataset(
    id="my_dataset",
    data_type="dynamodb",
    params={"tables": ["first_table", "second_table"], "main_table": "first_table"},
)

# For docdb
dataset = client.create_dataset(
    id="my_dataset",
    data_type="docdb",
    params={"collection": "my_collection"},
)
async def create_dataset_async(self, id: str, data_type: str, params: Dict[str, Any]) ‑> Dataset

Create a new dataset (async).

Args

  • id: (str) Unique identifier of a dataset
  • data_type: (str) Dataset type
  • params: (dict) Dataset parameters

Returns

Dataset

Example

# For dynamodb
dataset = await client.create_dataset_async(
    id="my_dataset",
    data_type="dynamodb",
    params={"tables": ["first_table", "second_table"], "main_table": "first_table"},
)

or

# For docdb
dataset = await client.create_dataset_async(
    id="my_dataset",
    data_type="docdb",
    params={"collection": "my_collection"},
)
def delete_dataset(self, id: str) ‑> None

Delete a dataset.

Args

  • id: (str) Unique identifier of a dataset

Example

client.delete_dataset(id="my_dataset")
async def delete_dataset_async(self, id: str) ‑> None

Delete a dataset (async)

Args

  • id: (str) Unique identifier of a dataset

Example

await client.delete_dataset_async(id="my_dataset")
def get_dataset(self, id: str) ‑> Dataset

Get a dataset.

Args

  • id: (str) Unique identifier of a dataset

Returns

Dataset

Example

dataset = client.get_dataset(id="my_dataset")
async def get_dataset_async(self, id: str) ‑> Dataset

Get a dataset (async).

Args

  • id: (str) Unique identifier of a dataset

Returns

Dataset

Example

dataset = await client.get_dataset_async(id="my_dataset")
def list_datasets(self) ‑> List[Dataset]

List datasets.

Returns

list(Dataset)

Example

datasets = client.list_datasets()
async def list_datasets_async(self) ‑> List[Dataset]

List datasets (async).

Returns

list(Dataset)

Example

datasets = await client.list_datasets_async()
def update_dataset(self, id: str, data_type: str, params: Dict[str, Any]) ‑> Dataset

Update a dataset.

Args

  • id: (str) Unique identifier of a dataset
  • data_type: (str) Dataset type
  • params: (dict) Dataset parameters

Returns

Dataset

Example

# For dynamodb
experiment = client.update_dataset(
    id="my_dataset",
    data_type="dynamodb",
    params={"tables": ["first_table", "second_table", "third_table"], "main_table": "second_table"}
)

# For docdb
experiment = client.update_dataset(
    id="my_dataset",
    data_type="docdb",
    params={"collections": "new_collections"}
)
async def update_dataset_async(self, id: str, data_type: str, params: Dict[str, Any]) ‑> Dataset

Update a dataset (async).

Args

  • id: (str) Unique identifier of a dataset
  • data_type: (str) Dataset type
  • params: (dict) Dataset parameters with tables and main_table

Returns

Dataset

Example

# For dynamodb
experiment = await client.update_dataset_async(
    id="my_dataset",
    data_type="dynamodb",
    params={"tables": ["first_table", "second_table", "third_table"], "main_table": "second_table"}
)

# For docdb
experiment = await client.update_dataset_async(
    id="my_dataset",
    data_type="docdb",
    params={"collections": "new_collections"}
)
def update_dataset_partial(self, id: str, data_type: str, params: Dict[str, Any] = None) ‑> Dataset

Partially update a dataset.

Args

  • id: (str) Unique identifier of a dataset
  • data_type: (optional) (str) Dataset type
  • params: (optional) (dict) Dataset parameters with tables and main_table

Returns

Dataset

Example

dataset = client.update_dataset_partial(
    id="my_dataset", params={"tables": ["first_table"], "main_table": "first_table"}
)
async def update_dataset_partial_async(self, id: str, data_type: str, params: Dict[str, Any] = None) ‑> Dataset

Partially update a dataset (async).

Args

  • id: (str) Unique identifier of a dataset
  • data_type: (optional) (str) Dataset type
  • params: (optional) (dict) Dataset parameters

Returns

Dataset

Example

dataset = await client.update_dataset_partial_async(
    id="my_dataset", params={"tables": ["first_table"], "main_table": "first_table"}
)
class QueryClient (config: Config)

Client for BAP Data API (/v1/query).

Example

import bap

client = bap.client("query")

Ancestors

Methods

def get_query(self, dataset_id: str, attributes: List[str] = None, query: Dict[str, Any] = None, sort: Dict[str, int] = None, limit: int = 100, headers: Dict[str, Any] = {}) ‑> List[Dict[str, Any]]

Get a data result.

Args

  • dataset_id: (str) Unique identifier of a dataset
  • attributes: (optional) (dict) Attributes to get from datasets
  • query: (optional) (dict) Query statement
  • sort: (optional) (dict) Sort statement with int index {"Ascending": 1, "Descending": -1}
  • limit: (optional) (int) Max number of items to get
  • headers: (optional) (dict) Headers being sent to API server

Returns

list

Example

data = client.get_query(
    dataset_id="my_dataset", attributes=["f1", "f2"], query={"f1": 100}, sort={"f1": 1, "f2": -1}, limit=5
)

async def get_query_async(self, dataset_id: str, attributes: List[str] = None, query: Dict[str, Any] = None, sort: Dict[str, int] = None, limit: int = 100, headers: Dict[str, Any] = {}) ‑> List[Dict[str, Any]]

Get a data result (async).

Args

  • dataset_id: (str) Unique identifier of a dataset
  • attributes: (optional) (dict) Attributes to get from datasets
  • query: (optional) (dict) Query statement
  • sort: (optional) (dict) Sort statement with int index {"Ascending": 1, "Descending": -1}
  • limit: (optional) (int) Max number of items to get
  • headers: (optional) (dict) Headers being sent to API server

Returns

list

Example

data = await client.get_query_async(
    dataset_id="my_dataset", attributes=["f1", "f2"], query={"f1": 100}, sort={"f1": 1, "f2": -1}, limit=5
)