Core Modules

This section provides detailed API documentation for the core modules of DeepChem Server, automatically generated from the source code docstrings.

Datastore Operations

The datastore module handles persistent storage of datasets and models.

class deepchem_server.core.datastore.DataStore[source]

Bases: object

Python API wrapper for deepchem server Backend data.

Each user of deepchem server has access to a personal backend datastore. The datastore is used to hold uploaded datasets and trained models. Users may refer to objects by their deepchem server datastore address and can use the deepchem server API to download them.

This abstract superclass provides a common datastore API that will be used to govern concrete Datastore implementations.

upload_data(datastore_filename: Any, filename: Any, card: ModelCard | DataCard) str | None[source]

Upload data to the datastore in question.

Parameters:
  • datastore_filename (Any) – The name of this dataset within your deepchem server datastore.

  • filename (Any) – Should be the location of a file on disk that is to be uploaded.

  • card (ModelCard or DataCard) – The card containing metadata for the uploaded data.

Returns:

If request failed, returns None. Else returns the deepchem server dataset address for the dataset in question.

Return type:

str or None

get(deepchem_address: str, kind: str | None, fetch_sample: bool)[source]

Fetch something from datastore at address.

Parameters:
  • deepchem_address (str) – Should be the location of a file on deepchem server datastore.

  • kind (str, optional) – ‘data’ or ‘model’ - used in cases which contain data in a directory and we need to find the contents of the directory as data or model.

  • fetch_sample (bool) – Whether to get sample or full data.

Returns:

The requested data or model object.

Return type:

Any

delete_object(deepchem_address: str)[source]

Delete an object pointed by the address from the datastore.

Parameters:

deepchem_address (str) – Location of object in the datastore.

Returns:

Result of the deletion operation.

Return type:

Any

list_data()[source]

List data uploaded to deepchem server datastore.

This method lists data that is present in deepchem server datastore for the present user.

Returns:

Representation of available data in the datastore.

Return type:

Any

__module__ = 'deepchem_server.core.datastore'
class deepchem_server.core.datastore.DiskDataStore(profile_name: str, project_name: str, basedir: str | None = None, sample_rows: int = 100)[source]

Bases: DataStore

A concrete datastore that stores objects on the local disk.

Initialize a disk datastore within the given directory.

Parameters:
  • profile_name (str) – Name of the profile.

  • project_name (str) – Name of the project.

  • basedir (str, optional) – Location on disk to hold data store. If none, create temporary folder.

  • sample_rows (int, optional) – Number of rows to get when fetching a sample instead of full data (works only for csv), by default {DEFAULT_SAMPLE_ROWS}.

__init__(profile_name: str, project_name: str, basedir: str | None = None, sample_rows: int = 100) None[source]

Initialize a disk datastore within the given directory.

Parameters:
  • profile_name (str) – Name of the profile.

  • project_name (str) – Name of the project.

  • basedir (str, optional) – Location on disk to hold data store. If none, create temporary folder.

  • sample_rows (int, optional) – Number of rows to get when fetching a sample instead of full data (works only for csv), by default {DEFAULT_SAMPLE_ROWS}.

upload_data_from_memory(data: Any, datastore_filename: str, card: DataCard | ModelCard | None, kind: str = 'data') str[source]

Upload in memory data to filestore.

Parameters:
  • data (Any) – Dataset to upload (ex: dataframe, image dataset etc).

  • datastore_filename (str) – The name of this dataset within your deepchem server datastore.

  • card (DataCard, ModelCard, or None) – Description of dataset for the dataset card.

  • kind (str, optional) – Type of data being uploaded, by default ‘data’.

Returns:

If request failed, returns None. Else returns the deepchem server dataset address for the dataset in question.

Return type:

str or None

Raises:
upload_data(datastore_filename: str, filename, card: ModelCard | DataCard, kind: str | None = 'data') str[source]

Upload data to DiskDataStore

Parameters:
  • datastore_filename (str) – The name of this dataset within your deepchem server datastore.

  • filename (str) – Should be the location of a file or directory on disk that is to be uploaded.

  • card (ModelCard or DataCard) – The card containing metadata for the uploaded data.

  • kind (Optional[str]) – Type of data being uploaded, by default ‘data’.

Returns:

dataset_address – If request failed, returns None. Else returns the deepchem server dataset address for the dataset in question.

Return type:

Optional[str]

add_dir(dir_name: str)[source]

Adds a directory to the DiskDataStore

Parameters:
  • dir_name (str) – Name of the directory to be added

  • ------

list_data()[source]

Lists data uploaded to deepchem server datastore.

This method lists data that is present in deepchem server datastore for the present user.

upload_model(modelname: str, model, card: ModelCard)[source]

Upload model data to DiskDataStore

Parameters:
  • modelname (str) – The name of the model in datastore.

  • model (dc.model.Model) – Model which is to be uploaded to datastore

  • card (str) – Description of model for the model card

Returns:

model_address – If request failed, returns None. Else returns the deepchem server model address for the uploaded model.

Return type:

Optional[str]

get_dir(address: str) str[source]

Returns the directory of the object

Parameters:

address (str) – DeepchemAddress of the object

Returns:

_dir – Directory of the object

Return type:

str

upload_model_from_memory(model_name: str, model_files: List[IO], model_filenames: List[str], card: ModelCard) str | None[source]

Upload model data to DiskDataStore

Parameters:
  • model_name (str) – The name of the model in datastore.

  • model_files (List[IO]) – List of file-like objects containing model files

  • model_filenames (List[str]) – List of filenames for the model files

  • card (str) – Description of model for the model card

Returns:

model_address – If request failed, returns None. Else returns the deepchem server model address for the uploaded model.

Return type:

Optional[str]

get_card(address: str, kind: str | None = 'data') DataCard | ModelCard | None[source]

Fetch card from disk data store at address.

Parameters:
  • address (str) – DeepchemAddress of the data object to retrieve.

  • kind (str, optional) – ‘data’ or ‘model’ - used in cases which contain data in a directory and we need to find the contents of the directory as data or model, by default ‘data’.

Returns:

The card object if found, None otherwise.

Return type:

DataCard, ModelCard, or None

get_data(address, fetch_sample: bool = False)[source]

Fetch data from disk data store at address

Parameters:
  • address – DeepchemAddress of the data object to retrieve

  • fetch_sample (bool) – Whether to get sample or full data (currently works only for csv files)

get_model(address)[source]

Fetch model from disk data store at address

Parameters:

address (DeepchemAddress of the data object to retrieve)

get(address, kind: str | None = 'data', fetch_sample: bool = False)[source]

Fetch something from disk datastore at address.

Parameters:
  • address – DeepchemAddress of the data object to retrieve

  • kind (Optional[str]) – ‘data’ or ‘model’ - used in cases which contain data in a directory and we need to find the contents of the directory as data or model

  • fetch_sample (bool) – Whether to get sample or full data (currently works only for csv files)

get_file_size(address: str) int[source]

Return size of the object.

Parameters:

address (str) – DeepchemAddress of the object.

Returns:

Size of the object in bytes.

Return type:

int

delete_object(address: str, kind: str = 'data') bool[source]

Delete an object from disk datastore.

Parameters:
  • address (str) – Address of the object.

  • kind (str, optional) – Type of object (‘data’, ‘model’, ‘dir’), by default ‘data’.

Returns:

True if deletion was successful.

Return type:

bool

download_object(address: str, filename: str | Path | None = None) None[source]

Downloads a object from disk datastore

Parameters:

address (str) – DeepchemAddress of the object

Return type:

None

Note

Dataset download is not meaningful in disk datastore since the dataset already exists in the disk. Hence, we make a copy of the file at the location specified by filename.

get_object_size(address: str) int[source]

Returns size of the object

Parameters:

address (str) – DeepchemAddress of the object

Returns:

object_size – Size of the object

Return type:

int

move_object(source_address: str, dest_address: str, dest_datastore: DiskDataStore) None[source]

Move an object from one location to another

Parameters:
  • source_address (str) – DeepchemAddress of the object to be moved

  • dest_address (str) – DeepchemAddress of the destination

  • dest_datastore (DiskDataStore) – DiskDataStore object of the destination

Return type:

None

copy_object(source_address: str, dest_address: str, dest_datastore: DiskDataStore) None[source]

Copy an object from one location to another

Parameters:
  • source_address (str) – DeepchemAddress of the object to be copied

  • dest_address (str) – DeepchemAddress of the destination

  • dest_datastore (DiskDataStore) – DiskDataStore object of the destination

Return type:

None

exists(address: str) bool[source]

Check if an object exists in the datastore

Parameters:

address (str) – DeepchemAddress of the object

Returns:

True if the object exists, False otherwise

Return type:

bool

__module__ = 'deepchem_server.core.datastore'
__repr__() str[source]

Return objects in the DiskDataStore.

Returns:

String representation of all objects in the datastore.

Return type:

str

Address Management

The address module provides URI-like addressing for resources.

Cards and Metadata

The cards module defines metadata structures for datasets and models.

Configuration

The config module manages server configuration settings.

Progress Logger

The progress_logger module logs the progress of the computation.

Model Mappings

The model_mappings module maps model types to their corresponding DeepChem models.

Model Config Mapping

The model_config_mapper module maps model types to their corresponding DeepChem models.

Compute Operations

The compute module handles computational tasks and job execution.