Skip to content

Latest commit

 

History

History
151 lines (107 loc) · 6.79 KB

2030.md

File metadata and controls

151 lines (107 loc) · 6.79 KB
title description date author tags
Upgrade PyKX from 2.5.* to 3.*
How to upgrade from PyKX 2.5.* to 3.*
October 2024
KX Systems, Inc.,
PyKX, upgrade, remote Python execution

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 #!python PYKX_BETA_FEATURES environment variable.

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

    === "Previous behaviour"

      ```bash
      pip install pykx[beta]
      ```
    

    === "New behaviour"

      ```bash
      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.

    === "Previous behaviour"

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

    === "New behaviour"

      ```python
      >>> 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 `#!python 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 `#!python 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 `#!python libraries` keyword and function take a dictionary mapping the aliased name for the library to the library which is to be imported, namely `#!python import numpy as np` would be defined as `#!python {'np': 'numpy'}`.
    

    === "Previous Behaviour"

      ```python
      >>> import pykx as kx
      >>> session = kx.remote.session()
      >>> session.create(host='localhost', port=5050)
      >>> session.add_library('numpy', 'pykx')
      ```
    

    === "New Behaviour"

      ```python
      >>> 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 #!python clear method provided for #!python session objects is now called #!python 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

    === "Previous Behaviour"

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

    === "New Behaviour"

      ```python
      >>> 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 #!python modify keyword for #!python select, #!python exec, #!python update and #!python delete operations on #!python pykx.Table and #!python pykx.KeyedTable. This has been permanently changed to be use #!python inplace.

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

Error message changes

Various #!python 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.