Skip to content

Upgrade from PyKX 2.5.* to 3.*

This page outlines key differences when upgrading PyKX versions from 2.5.* to 3.*.

API Changes

Remote Python execution

  • Remote Python Execution is no longer a Beta feature. To use this feature, remove the setting of the PYKX_BETA_FEATURES environment variable.

  • Additional required dependencies for this feature are now part of the required dependencies.

    pip install pykx[beta]
    pip install pykx
  • Generation of a remote session which can be used previously was a two-step process:

    1. Initialize the session object
    2. Create the session

    This changed to a single function call.

    >>> import pykx as kx
    >>> session = kx.remote.session()
    >>> session.create(host='localhost', port=5050)
    >>> import pykx as kx
    >>> session = kx.remote.session(host='localhost', port=5050)
  • How users specify the Python libraries which should be available on remote processes has changed:

    • Previously this was done using a function call to session.add_library. This function would specify the libraries to be loaded on first execution of the function and expected the names of the libraries to be loaded as a list of arguments.
    • Now you can use the keyword libraries at session creation to load the libraries. Also, the library addition function is now called session.libraries to match the API for streaming with PyKX. Finally the libraries keyword and function take a dictionary mapping the aliased name for the library to the library which is to be imported, namely import numpy as np would be defined as {'np': 'numpy'}.
    >>> import pykx as kx
    >>> session = kx.remote.session()
    >>> session.create(host='localhost', port=5050)
    >>> session.add_library('numpy', 'pykx')
    >>> import pykx as kx
    # Initialise libraries at session creation
    >>> session = kx.remote.session(port=5050, libraries = {'kx': 'pykx', 'np': 'numpy'})
    
    # Add Libraries after session creation
    >>> session = kx.remote.session(port=5050)
    >>> session.libraries({'kx': 'pykx', 'np': 'numpy'})
  • The clear method provided for session objects is now called close. This change aligns the naming with IPC communication channels being 'closed' when stopping communication with a remote session and aligns with the naming used within the IPC module

    >>> import pykx as kx
    >>> session = kx.remote.session()
    >>> session.create(host='localhost', port=5050)
    >>> session.clear()
    >>> import pykx as kx
    >>> session = kx.remote.session(host='localhost', port=5050)
    >>> session.close() 

Deprecations

  • The following table outlines environment variables/configuration options which are now fully deprecated and the updated name for these values if they exist.

    Deprecated option Supported option
    PYKX_NO_SIGINT PYKX_NO_SIGNAL
    IGNORE_QHOME PYKX_IGNORE_QHOME
    KEEP_LOCAL_TIMES PYKX_KEEP_LOCAL_TIMES
    SKIP_UNDERQ PYKX_SKIP_UNDERQ
    UNDER_PYTHON PYKX_UNDER_PYTHON
    UNSET_PYKX_GLOBALS No longer applicable
    PYKX_UNSET_GLOBALS No longer applicable
    PYKX_ENABLE_PANDAS_API No longer applicable
  • Removal of the now deprecated modify keyword for select, exec, update and delete operations on pykx.Table and pykx.KeyedTable. This has been permanently changed to be use inplace.

  • Removal of the deprecated replace_self keyword when attempting to overwrite a pykx.Table or KeyedTable using insert/upsert functionality. To maintain this behaviour use the #python inplace keyword.

Error message changes

Various pykx.QError error messages now provide more verbose explanations for users. Any code which relies on specific error string returns may need to be updated, some messages below are truncated for display purposes.

Previous error message Updated error message
access access: Failed to connect to server with invalid username/password
par par: Cannot execute an unsupported operation on a partitioned table or its ...
splay splay: Cannot execute an unsupported operation on a splayed table
assign assign: Cannot redefine reserved q word
insert insert: Cannot insert a record with an existing key into a keyed table
s-fail s-fail: Cannot set "sorted" attribute on an unsorted list ...
u-fail u-fail: Failed to do one of the following: ...
no-update noupdate: Cannot update a global variable while using: ...
no-socket nosocket: Cannot open or use a socket on a thread other than main. ...

Null and Infinite conversion changes

PyKX previously left some null and infinite values unconverted, now these are converted to native Python objects. The behaviour of Atom and Vector conversions has also been updated to more closely match each other.

The links below outline the full before and after behaviour.

Pandas 2.2.X Update

PyKX now works with Pandas 2.2.X, introducing some breaking changes in behavior. Specifically, the .equals method now checks the _mgr type of DataFrames, which can result in unilateral behavior when comparing PyKX and Pandas objects.

These changes may affect compatibility with code written for earlier versions of Pandas.

The link below outline the full details of the changes and their implications.