mspasspy.client#

class mspasspy.client.Client(database_host=None, scheduler=None, scheduler_host=None, job_name='mspass', database_name='mspass', schema=None, collection=None, dask_client=None)[source]#

Bases: object

A client-side representation of MSPASS.

This is the only client users should use in MSPASS. The client manages all the other clients or instances. It creates and manages a Database client. It creates and manages a Global Hisotry Manager. It creates and manages a scheduler(spark/dask)

For the address and port of each client/instances, we first check the user specified parameters, if not then serach the environment varibales values, if not againm then use the default settings.

An existing dask.distributed.Client can be supplied with dask_client. This is useful for externally managed Dask clusters, including Dask Gateway clusters. The caller owns the external cluster and should keep it alive while the MsPASS client is using it.

get_database(database_name=None)[source]#

Get a database by database_name, if database_name is not specified, use the default one

Parameters:

database_name (str) – the name of database

Returns:

mspasspy.db.database.Database

get_database_client()[source]#

Get the database client in the global history manager

Returns:

mspasspy.db.database.Database

get_global_history_manager()[source]#

Get the global history manager with this client

Returns:

mspasspy.global_history.manager.GlobalHistoryManager

get_scheduler()[source]#

Get the scheduler(spark/dask) with this client

Returns:

pyspark.SparkContext/dask.distributed.Client/None

set_database_client(database_host, database_port=None)[source]#

Set a database client by database_host(and database_port)

Parameters:
  • database_host (str) – the host address of database client

  • database_port (str) – the port of database client

set_global_history_manager(history_db, job_name, collection=None)[source]#

Set a global history manager by history_db, job_name(and collection)

Parameters:
  • history_db (mspasspy.db.database.Database) – the database will be set in the global history manager

  • job_name (str) – the job name will be set in the global history manager

  • collection (str) – the collection name will be set in the history_db

set_scheduler(scheduler, scheduler_host, scheduler_port=None)[source]#

Set a scheduler by scheduler type, scheduler_host(and scheduler_port)

Parameters:
  • scheduler (str) – the scheduler type, should be either dask or spark

  • scheduler_host (str) – the host address of scheduler

  • scheduler_port (str) – the port of scheduler