mspasspy.client
- class mspasspy.client.Client(database_host=None, scheduler=None, scheduler_host=None, job_name='mspass', database_name='mspass', schema=None, collection=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.
- 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:
- 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 clientdatabase_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 managerjob_name (
str
) – the job name will be set in the global history managercollection (
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 sparkscheduler_host (
str
) – the host address of schedulerscheduler_port (
str
) – the port of scheduler