Pyot requires many setups and configurations in order to work properly. Models cannot be imported until the related confs are evaluated (raises
Model ... is inactive).
These configurations generally stays all packed in a single file (generally called
pyotconf.py) or one file per model, they must be loaded once and only once at application startup.
If an integration of Pyot to another framework is needed. General integration guides are provided for Django, FastAPI and Celery projects at the Integrations section. These guides does not require to be strictly followed and only serves for reference purposes.
Setup, configure and activate the models of need. Define the default platform, region, version and locale, these are used for default values in class init definitions and object bridging. For a list of correct platforms and regions, they are documented under each models main page.
name: Name of model
Setup, configure and activate a pipeline for the activated models. A pipeline is a list of prioritized data sources that a model will request data from. You may define and activate multiple pipelines under some circumstances, but one and only one default pipeline must exists for each model.
Global models are not configurable as an standalone pipeline, such as
riot, because objects of multiple other models can access these models objects in their own pipelines. They are configured as part of other models pipelines.
name: Name of model this pipeline belongs to
strName of this pipeline
boolIs this the default pipeline
List[Dict[str, Any]]List of data stores, the earlier the store is located in the list, the higher the priority. Each store has it's own configurations, they are documented in the Stores section.
A variety of stores is provided, including caches (e.g. Redis, MongoDB) and services (e.g. RiotAPI, CDragon). Cache stores must be placed at higher priority than any service stores.
For cache stores, multiple stores of the same backend can be configured, it may be useful for scenarios where different types of objects should be cached in different places (e.g. Two
DiskCaches with different directory for storing lol matches and lol timelines).
If you wish to pack everything into a single file project, put all conf at the top of your file, and skip importing. This is generally not recommended.
Conf files can be imported in following ways:
- Manually importing the conf file in python syntax.
- If an integration is being used (e.g. Django), check if the integration has a custom conf import hook and use it instead.
path_or_paths: Import path or list of import paths to the conf files.
Import path is the path used as if the file/module is being imported using python syntax via
Example configuration of
lolmodel and a default pipeline including a cache store that caches summoners for 100 seconds, matches and timelines for 10 minutes; and service stores for CDragon and RiotAPI:
from pyot.conf.model import activate_model, ModelConf
from pyot.conf.pipeline import activate_pipeline, PipelineConf
default_platform = "na1"
default_region = "americas"
default_version = "latest"
default_locale = "en_us"
name = "lol_main"
default = True
stores = [
Now import the confs into your application:
from pyot.conf.utils import import_confs