Table Of Contents
Table Of Contents

gluonts.testutil.shell module

class gluonts.testutil.shell.ServerFacade(base_address: str)[source]

Bases: object

A convenience wrapper for sending requests and handling responses to an inference server located at the given address.

batch_invocations(data_entries: Iterable[Dict[str, Any]]) → List[dict][source]
execution_parameters() → dict[source]
invocations(data_entries: Iterable[Dict[str, Any]], configuration: dict) → List[dict][source]
ping() → bool[source]
url(path) → str[source]
gluonts.testutil.shell.free_port() → int[source]

Returns a random unbound port.

gluonts.testutil.shell.temporary_serve_env(predictor: gluonts.model.predictor.Predictor) → ContextManager[gluonts.shell.sagemaker.ServeEnv][source]

A context manager that instantiates a serve environment for a given Predictor in a temporary directory and removes the directory on exit.

Parameters:predictor – A predictor to serialize in ServeEnv model folder.
Returns:A context manager that yields the ServeEnv instance.
Return type:ContextManager[TrainEnv]
gluonts.testutil.shell.temporary_server(env: gluonts.shell.sagemaker.ServeEnv, forecaster_type: Optional[Type[gluonts.model.predictor.Predictor]], settings: gluonts.shell.serve.Settings = Settings(model_server_workers=None, max_content_length=6291456, sagemaker_server_address=IPv4Address('0.0.0.0'), sagemaker_server_port=8080, sagemaker_server_timeout=100, sagemaker_batch=False, sagemaker_batch_strategy='SINGLE_RECORD', sagemaker_max_payload_in_mb=6, sagemaker_max_concurrent_transforms=4294967295)) → ContextManager[gluonts.testutil.shell.ServerFacade][source]

A context manager that instantiates a Gunicorn inference server in a separate process (using the make_inference_server() call)

Parameters:
  • env – The ServeEnv to use in static inference mode. Either env or forecaster_type must be set.
  • forecaster_type – The Predictor type to use in dynamic inference mode. Either env or forecaster_type must be set.
  • settings – Settings to use when instantiating the Gunicorn server.
Returns:

A context manager that yields the InferenceServer instance wrapping the spawned inference server.

Return type:

ContextManager[ServerFacade]

gluonts.testutil.shell.temporary_train_env(hyperparameters: Dict[str, Any], dataset_name: str) → ContextManager[gluonts.shell.sagemaker.TrainEnv][source]

A context manager that instantiates a training environment from a given combination of hyperparameters and dataset_name in a temporary directory and removes the directory on exit.

Parameters:
  • hyperparameters – The name of the repository dataset to use when instantiating the training environment.
  • dataset_name – The name of the repository dataset to use when instantiating the training environment.
Returns:

A context manager that yields the TrainEnv instance.

Return type:

ContextManager[TrainEnv]