negmas.config

Configuration management for NegMAS. This module handles loading and accessing configuration values from various sources.

Overview

NegMAS configuration values are read from multiple sources in the following priority order (highest to lowest):

  1. Environment variables with the prefix NEGMAS_ (e.g., NEGMAS_GENIUS_BRIDGE_JAR)

  2. Local configuration file negmasconf.json in the current working directory

  3. User configuration file at the path specified by NEGMAS_DEFAULT_PATH environment variable

  4. Default user configuration at ~/negmas/config.json

  5. Default values hardcoded in the library

Configuration Keys

The following configuration keys are available:

Key

Description

genius_bridge_jar

Path to the Genius bridge JAR file for Java integration

jnegmas_jar

Path to the JNegMAS JAR file

warn_slow_ops

Threshold for warning about slow operations (number of operations)

Usage

To access configuration values programmatically:

from negmas.config import negmas_config

# Get the path to the Genius bridge JAR
jar_path = negmas_config("genius_bridge_jar", default="/path/to/default.jar")

# Get warning threshold with default
threshold = negmas_config("warn_slow_ops", default=100_000_000)

Configuration File Format

Configuration files should be JSON format:

{
    "genius_bridge_jar": "/path/to/geniusbridge.jar",
    "jnegmas_jar": "/path/to/jnegmas.jar",
    "warn_slow_ops": 100000000
}

API Reference

Defines basic config for NEGMAS

negmas.config.CONFIG_KEY_GENIUS_BRIDGE_JAR = 'genius_bridge_jar'[source]

Key name for the Genius bridge jar in NEGMAS_CONFIG

negmas.config.CONFIG_KEY_JNEGMAS_JAR = 'jnegmas_jar'[source]

Key name for the JNegMAS jar in NEGMAS_CONFIG

negmas.config.negmas_config(key: str, default: T) T[source]

Returns the config value associated with the given key.

Remarks:
  • config values are read from the following sources (in descending order of priority):
    • Environment variable with the name NEGMAS_{key} (with the key converted to all uppercase)

    • Local file called negmasconf.json (with the key all lowercase)

    • json file stored at the location indicated by environment variable “NEGMAS_DEFAULT_PATH” (with the key all lowercase)

    • ~/negmas/config.json (with the key all lowercase)

    • A default value hardcoded in the negmas library. For paths, this usually lies under ~/negmas