Configuration

Configuration of the Core Package

Several constants that control numerical or algorithmic behavior are defined in the Config class. The class supports determining the configuration values in 3 ways: by predefined default value, by environment variables and by setting through Python code. The default value is the value set in the class definition as listed below. Environment variables following the pattern PYROLL_CORE_<NAME_OF_THE_CONSTANT> can be used to set the configuration from the shell environment. The prefix PYROLL_CORE is required for the config class of the pyroll.core package. Other package may define their own config classes with different prefixes, see their respective documentation.

To set an environment variable under Unix, execute the following before executing a PyRolL script or the PyRolL CLI. You may also add the following line to your shell’s run configuration (.bashrc, .zshrc, …) to have it always present when launching a new shell.

export PYROLL_CORE_DEFAULT_MAX_ITERATION_COUNT=50

Under Windows, you have to edit the environment variables using the system settings.

You can also set the value in Python code like any other variable. This type of setting takes precedence over environment variables.

from pyroll.core import Config

Config.DEFAULT_MAX_ITERATION_COUNT = 50
class Config

Configuration class for pyroll.core.

DEFAULT_ITERATION_PRECISION = 0.001

Default precision of iteration loops required to break successfully.

DEFAULT_MAX_ITERATION_COUNT = 100

Default maximum count of iterations before aborting the loop.

GROOVE_PADDING = 0.2

Fraction of the total groove width that is added at the sides of the groove contour to represent the roll face.

ROLL_PASS_AUTO_ROTATION = True

Whether to enable automatic rotation of incoming profiles in roll passes by default.

ROLL_SURFACE_DISCRETIZATION_COUNT = 100

Count of discrete points used to describe the roll surface.

Creating Configurations for Plugin Packages

If you are developing your own plugin or extension you may create your own config class using the config() decorator. The only argument to this decorator is the prefix used for the environment variables (like PYROLL_CORE above).

config(env_var_prefix)

Decorator for creating config classes. Automatically creates a metaclass with respective ConfigValue descriptors for class attributes with uppercase names that do not start with underscore.

Use it as follows:

@config("PREFIX")
class Config:
    VAR1 = 42
    VAR2 = "abc"

    # not modified
    _PRIV_VAR = None
    normal_var = None
Parameters:

env_var_prefix – prefix for the respective env vars, should be uppercase and delimited by underscores