Table Of Contents
Table Of Contents

gluonts.shell.testutil module

gluonts.shell.testutil.free_port() → int[source]

Returns a random unbound port.

gluonts.shell.testutil.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.shell.testutil.temporary_server(env: Optional[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.shell.serve.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.shell.testutil.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]