httpstan.cache

Cache management.

Functions in this module manage the Stan model cache and related caches.

Module Contents

Functions

cache_directory() → pathlib.Path

Get httpstan cache path.

model_directory(model_name: str) → pathlib.Path

Get the path to a model's directory. Directory may not exist.

fit_path(fit_name: str) → pathlib.Path

Get the path to a fit file. File may not exist.

delete_model_directory(model_name: str) → None

Delete the directory in which a model and associated fits are stored.

dump_services_extension_module_compiler_output(compiler_output: str, model_name: str) → None

Dump compiler output from building a model-specific stan::services extension module.

load_services_extension_module_compiler_output(model_name: str) → str

Load compiler output from building a model-specific stan::services extension module.

list_model_names() → List[str]

Return model names (e.g., models/dyeicfn2) for models in cache.

dump_stanc_warnings(stanc_warnings: str, model_name: str) → None

Dump stanc warnings associated with a model.

load_stanc_warnings(model_name: str) → str

Load stanc output associated with a model.

dump_fit(fit_bytes: bytes, name: str) → None

Store Stan fit in filesystem-based cache.

load_fit(name: str) → bytes

Load Stan fit from the filesystem-based cache.

delete_fit(name: str) → None

Delete Stan fit from the filesystem-based cache.

Attributes

logger

httpstan.cache.logger
httpstan.cache.cache_directory() pathlib.Path[source]

Get httpstan cache path.

httpstan.cache.model_directory(model_name: str) pathlib.Path[source]

Get the path to a model’s directory. Directory may not exist.

httpstan.cache.fit_path(fit_name: str) pathlib.Path[source]

Get the path to a fit file. File may not exist.

httpstan.cache.delete_model_directory(model_name: str) None[source]

Delete the directory in which a model and associated fits are stored.

httpstan.cache.dump_services_extension_module_compiler_output(compiler_output: str, model_name: str) None[source]

Dump compiler output from building a model-specific stan::services extension module.

httpstan.cache.load_services_extension_module_compiler_output(model_name: str) str[source]

Load compiler output from building a model-specific stan::services extension module.

httpstan.cache.list_model_names() List[str][source]

Return model names (e.g., models/dyeicfn2) for models in cache.

httpstan.cache.dump_stanc_warnings(stanc_warnings: str, model_name: str) None[source]

Dump stanc warnings associated with a model.

httpstan.cache.load_stanc_warnings(model_name: str) str[source]

Load stanc output associated with a model.

httpstan.cache.dump_fit(fit_bytes: bytes, name: str) None[source]

Store Stan fit in filesystem-based cache.

The Stan fit is passed via fit_bytes. The content must already be compressed.

Parameters
  • name – Stan fit name

  • fit_bytes – gzip-compressed messages associated with Stan fit.

httpstan.cache.load_fit(name: str) bytes[source]

Load Stan fit from the filesystem-based cache.

Parameters
  • name – Stan fit name

  • model_name – Stan model name

Returns

gzip-compressed messages associated with Stan fit.

httpstan.cache.delete_fit(name: str) None[source]

Delete Stan fit from the filesystem-based cache.

Parameters

name – Stan fit name