Logging and errors

IPKISS provides warnings and errors to inform users when something is wrong or requires attention.

There are several types of logging and errors:

  • Python Exception

    IPKISS throws a Python Exception when an error occurs that cannot be resolved. This may happen when the user supplied a fundamentally wrong input.

  • Deprecation Warnings

    When using deprecated parts of the IPKISS API, IPKISS throws a warning (IpkissDeprecationWarning). These warnings appear only once for each occurrence in the user’s code and do not stop execution but encourage the user to update their code to be future-proof. When a deprecated feature reaches its removal time (see Deprecation policy), an IpkissFinalDeprecationWarning is thrown.

  • Non-Critical Warnings and Errors

    In cases where an issue does not halt IPKISS execution but may still require intervention, IPKISS logs a warning or error to the user. For example, this can occur when layout specification cannot be met, or a file could not be exported, but IPKISS can continue to provide a first useful output. Users should address and correct these warnings by updating the code or design.

  • General and Debug Information

    Besides errors and warnings, IPKISS also outputs general and debug information. By default, these are not visible to the user.

All this information is logged to the console. When using the Link for Siemens EDA, information is also logged to a file, see Link for Siemens EDA logging configuration.

Configuring logging

The visibility of logged information (errors, warnings, information, …) can be configured using a logging level. Deprecation warnings are always shown, but you can configure whether they allow execution to continue or halt the program. Exceptions that halt execution cannot be configured. They will always be raised and visible to the user.

Controlling the level of logged information

The logging level (a.k.a. loglevel) allows control over the visibility of logged information that does not halt the program.

It follows Python’s logging package levels:

  • ERROR: A serious error has happened and the software has not been able to perform some function, but will still continue.

  • WARNING: Indication of unexpected events that require user attention and may need input, though the program continues to function normally.

  • INFO: Confirmation that things are working as expected, e.g. that a file export that might take some time has started.

  • DEBUG: Detailed information, only of interest when an issue needs to be debugged. This level is currently rarely used in IPKISS.

The default logging level is WARNING, meaning that warnings and errors are shown to the user. Adjusting the level to `INFO` will show all errors, warnings, and informational messages.

The logging level can be modified with the set_log_level function:

from ipkiss3 import all as i3
i3.set_log_level("ERROR")
# warnings will not be logged in the remainder of the code, except for deprecation warnings

Alternatively, the logging level can be controlled through the LUCEDA_LOG_LEVEL environment variable. When not set, the default is WARNING.

Controlling deprecation warnings

By default, IPKISS shows deprecation warnings without halting the program.

For testing purposes, e.g. when using Luceda IP Manager, you may want to treat a deprecation warning as an error instead. In that way you will force yourself to update your code to be future-proof.

Luceda IP Manager is based on pytest. To treat deprecation warnings as errors and display all deprecation messages, configure your pytest.ini file (see Ini file) as follows:

[pytest]
addopts = '--html=report.html' '--self-contained-html'
filterwarnings =
    error::luceda.logging.deprecation.IpkissFinalDeprecationWarning
    always::luceda.logging.deprecation.IpkissDeprecationWarning

If you want to treat warnings as errors for a single Python script and all the modules it imports, add the following at the top of your script:

import warnings

warnings.filterwarnings("error")

What the log can tell you

The following list explains what you can expect after enabling the logging:

  1. Version and packages used (DEBUG): When DEBUG is enabled, IPKISS will print the version of each of the top-level packages that it uses (i.e., IPKISS, PICAZZO, AWG_DESIGNER, …). Example:

    IPKISS version X.Y.Z - copyright Luceda N.V., 2002-YYYY (i-depot BBIE 7396, 7556, 7748, 058652)
    This software package is part of a commercial product.
    It contains components and functionalities which are confidential.
    Do not distribute this code under any circumstances.
    Refer new users to sales@lucedaphotonics.com to obtain a valid license.
    
  2. Code checking (WARNING): starting from the WARNING level, IPKISS provides warnings about inconsistent or deprecated code. For instance, if a property named length is used with a function define_length, IPKISS will recommend using _default_length instead:

    Deprecation: Please use _default_length instead of define_length in class <class 'mylibrary.filters.ring.RingResonator'>