Skip to main content

Strict Mode for Configuration (strict)

The strict parameter on ArgusClient.create() controls how the client handles non-critical, client-side configuration errors. This is particularly useful for policies that require non-empty lists of parameters.
  • strict=True(Default): This is the recommended and safest mode for production. If you enable a policy that requires metadata but provide an invalid configuration (e.g., BANNED_TOPICS with an empty topics list), the client will immediately raise an ArgusValueError. This prevents you from running with a misconfigured policy.
    # This will raise ArgusValueError because 'topics' cannot be empty.
    try:
        client = ArgusClient.create(
            api_key=API_KEY,
    		url="https://argususapi.repello.ai/sdk/v1",
            strict=True,
            policy={PolicyName.BANNED_TOPICS: {"action": Action.BLOCK, "topics": []}}
        )
    except ArgusValueError as e:
        print(f"Caught expected error: {e}")
    
    
    
  • strict=False: In the same scenario, the client will instead issue a UserWarning and proceed. This can be useful during rapid development or testing but is not recommended for production environments where configuration must be precise.
    # This will print a UserWarning to the console and create the client.
    import warnings
    
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        client = ArgusClient.create(
            api_key=API_KEY,
    		url="https://argususapi.repello.ai/sdk/v1",
            strict=False,
            policy={PolicyName.BANNED_TOPICS: {"action": Action.BLOCK, "topics": []}}
        )
        print(f"Caught expected warning: {w[-1].message}")