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_FEATURESenvironment 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:
- Initialize the session object
- 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
librariesat session creation to load the libraries. Also, the library addition function is now calledsession.librariesto match the API for streaming with PyKX. Finally thelibrarieskeyword and function take a dictionary mapping the aliased name for the library to the library which is to be imported, namelyimport numpy as npwould 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'}) - Previously this was done using a function call to
-
The
clearmethod provided forsessionobjects is now calledclose. 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_SIGINTPYKX_NO_SIGNALIGNORE_QHOMEPYKX_IGNORE_QHOMEKEEP_LOCAL_TIMESPYKX_KEEP_LOCAL_TIMESSKIP_UNDERQPYKX_SKIP_UNDERQUNDER_PYTHONPYKX_UNDER_PYTHONUNSET_PYKX_GLOBALSNo longer applicable PYKX_UNSET_GLOBALSNo longer applicable PYKX_ENABLE_PANDAS_APINo longer applicable -
Removal of the now deprecated
modifykeyword forselect,exec,updateanddeleteoperations onpykx.Tableandpykx.KeyedTable. This has been permanently changed to be useinplace. - Removal of the deprecated
replace_selfkeyword when attempting to overwrite apykx.TableorKeyedTableusing insert/upsert functionality. To maintain this behaviour use the#python inplacekeyword.
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.