Forum Replies Created

Page 9 of 21
  • rocuinneagain

    Member
    August 9, 2023 at 12:00 am in reply to: Calling/using a Python function or Class from Q

    Updating that link to download with PyKX flags must be done using the insights link specifically:

    https://kx.com/kdb-insights-personal-edition-license-download/

  • rocuinneagain

    Member
    July 21, 2023 at 12:00 am in reply to: PyKX is now open source!

    PyKX source is available on Github: https://github.com/KxSystems/pykx

  • PyKX 1.6.1 has been released. Full details on the release can be found here.Highlights: Added sorted, grouped, parted, and unique. As methods off of Tables and Vectors. Added PyKXReimport class to allow subprocesses to reimport PyKX safely. Details here. Added environment variables to specify a path to libpython. Details here. Fixed memory leaks in QConnection and PyKX as a server. Fixed bug in Jupyter Notebook magic command. Full details including many other fixes included here. import pykx as kx with kx.PyKXReimport(): output = subprocess.run( (str(Path(sys.executable).as_posix()), ‘-c’, ‘import pykx; print(pykx.q(“til 10”))’), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, ).stdout.strip() assert output == “0 1 2 3 4 5 6 7 8 9”

  • PyKX 1.6.1 has been released. Full details on the release can be found here.
    Highlights:
    • Added sortedgroupedparted, and unique. As methods off of Tables and Vectors.
    • Added PyKXReimport class to allow subprocesses to reimport PyKX safely. Details here.
    • Added environment variables to specify a path to libpython. Details here.
    • Fixed memory leaks in QConnection and PyKX as a server.
    • Fixed bug in Jupyter Notebook magic command.
    Full details including many other fixes included here.

    import pykx as kx

    with kx.PyKXReimport():

    output = subprocess.run(

    (str(Path(sys.executable).as_posix()), ‘-c’, ‘import pykx; print(pykx.q(“til 10”))’),

    stdout=subprocess.PIPE,

    stderr=subprocess.STDOUT,

    text=True,

    ).stdout.strip()

    assert output == “0 1 2 3 4 5 6 7 8 9”

     

  • rocuinneagain

    Member
    July 12, 2023 at 12:00 am in reply to: Navigating a nested object using apply.

    Use :: to skip a level

     

     

    q)thing:(`procData`!(((`;`$”_source”)!(`;(`a`metadata!1 2;`b`metadata!3 4));`);`);`) q)thing `procData`!((“_source!(`;(`a`metadata!1 2;`b`metadata!3 4));`);`) ` q).[thing;(0;`procData;0;`$”_source”)] `a`metadata!1 2 `b`metadata!3 4 q).[thing;(0;`procData;0;`$”_source”;::;`metadata)] 2 4

     

    https://code.kx.com/q/ref/apply/#nulls-in-i

     

  • rocuinneagain

    Member
    July 12, 2023 at 12:00 am in reply to: Calling/using a Python function or Class from Q

    pykx.q provides this functionality. Most EmbedPy code can be migrated by replacing .p with .pykx

    https://code.kx.com/pykx/1.6/api/pykx_under_q.html

    The needed file is included when you pip install pykx

    To make it available to your q processes run the commend to copy the needed files:

     

     

    python -c "import pykx as kx; kx.install_into_QHOME()"

     

     

    Then you can use as you describe:

     

     

     

    l pykx.q 
    np:.pykx.import`numpy 
    np[`:arange][10]` 
    0 1 2 3 4 5 6 7 8 9

     

     

     

    There are still some improvements needed to reach parity/maturity which will be coming in the next few releases of PyKX.

     

    License flags are needed to use this feature but they are now provided to all downloads.

    You can check your license in q

     

     

     

    q)`insights.lib.embedq`insights.lib.pykx in: `$" " vs .z.l 4 
    11b

     

     

     

    If you do not have the flags you just need to re download and a new license with the flags will be included.

    https://kx.com/kdb-personal-edition-download/ 

    https://kx.com/kdb-insights-personal-edition-license-download/

  • rocuinneagain

    Member
    July 11, 2023 at 12:00 am in reply to: PyKX license error

    Can you run these 2 commands in your command prompt and share the output?

     

    set QARGS="--unlicensed" 
    python -c "import pykx;pykx.util.debug_environment()"

     

     

    This is the output for me:

     

    **** PyKX information **** 
    pykx.args: ('--unlicensed',) 
    pykx.qhome: C:q 
    pykx.qlic: C:q 
    pykc.licensed: False
    pykx.__version__: 1.6.0 
    pykx.file: C:UsersrocuinneagainAppDataLocalPackagesPythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0LocalCachelocal-packagesPython310site-packagespykxutil.py 
    
    **** Python information **** 
    sys.version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
    pandas: 1.5.3 
    numpy: 1.25.0 
    pytz: 2022.7.1 
    which python: C:UsersrocuinneagainAppDataLocalMicrosoftWindowsAppspython.EXE 
    which python3: C:UsersrocuinneagainAppDataLocalMicrosoftWindowsAppspython3.EXE 
    
    **** Platform information **** 
    platform.platform: Windows-10-10.0.19045-SP0 
    
    **** Environment Variables **** 
    IGNORE_QHOME:
    KEEP_LOCAL_TIMES: 
    PYKX_ALLOCATOR: 
    PYKX_ENABLE_PANDAS_API: 
    PYKX_GC: 
    PYKX_LOAD_PYARROW_UNSAFE: 
    PYKX_MAX_ERROR_LENGTH: 
    PYKX_NOQCE: 
    PYKX_Q_LIB_LOCATION: 
    PYKX_RELEASE_GIL: 
    PYKX_Q_LOCK: 
    QARGS: "--unlicensed" 
    QHOME: C:q 
    QLIC: C:q 
    PYKX_DEFAULT_CONVERSION: 
    SKIP_UNDERQ: 
    UNSET_PYKX_GLOBALS: 
    
    **** License information **** 
    pykx.qlic directory: True 
    pykx.lic writable: True 
    pykx.qhome lics: ['k4.lic', 'kc.lic'] 
    pykx.qlic lics: ['k4.lic', 'kc.lic'] 
    
    **** q information **** 
    which q: C:qw64q.EXE 
    q info: (`w64;4f;2023.04.17) 
    "insights.lib.embedq insights.lib.pykx insights.lib.sql insights.lib.qlog insights.lib.kurl insights.lib.objstore insights.lib.bigquery insights.lib.restserver"

     

     

    Note:

    • QLIC must point to the folder containing the licence, it should not point to the the file itself.
    • The license needs to have the flags  insights.lib.embedq insights.lib.pykx

     

     

  • rocuinneagain

    Member
    July 10, 2023 at 12:00 am in reply to: Running kdb on apple silicon

    The notes on this thread might help:

    Installation for ARM64 – KX Community – 13568

  • rocuinneagain

    Member
    July 3, 2023 at 12:00 am in reply to: OpenSSL 3.0.8 not compatible with PyKX?

    This message is warning about the underlying kurl.q library only.

    PyKX has still imported and will still function (apart from any kurl features)

    If you wish to use kurl then the requirements are listed here:

  • rocuinneagain

    Member
    June 28, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command error

    No it only needs to be done once.

     

    Normally importing PyKX should run it automatically but for some reason your install does not do this.

  • rocuinneagain

    Member
    June 28, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command error

    No it only needs to be done once. Normally importing PyKX should run it automatically but for some reason your install does not do this.

  • rocuinneagain

    Member
    June 28, 2023 at 12:00 am in reply to: Storage architecture for KDB

    Some inbuilt functions do make assumptions around how data is stored for segmented databases.

    The functions assume each date is stored in the segment entry matching modulus of the date by the number of par.txt entries .i.e round robin.

    See related thread:

    Solved: .Q.par Doesn’t Provide the Correct Result in the S… – KX Community – 14220

    And warning: https://code.kx.com/q/database/segment/#considerations

    “Partition data correctly: data for a particular date must reside in the partition for that date.”

     

    However for querying and normal operations where these functions are not called there is no such requirement.

     

    Symlinking is used often in kdb+ systems for flexibility around storage layouts.

  • rocuinneagain

    Member
    June 28, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command error

    As this ran without error you should now be able to use your query:

    >>> pykx.q('l s.k_') 
    pykx.Identity(pykx.q('::'))

    Should now run:

    kx.q.sql('select * from trades')
  • rocuinneagain

    Member
    June 28, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command error

    As this ran without error you should now be able to use your query: >>> pykx.q(‘l s.k_’) pykx.Identity(pykx.q(‘::’)) Should now run: kx.q.sql(‘select * from trades’)

  • rocuinneagain

    Member
    June 27, 2023 at 12:00 am in reply to: kx.q.sql(‘select * from trades’) command error

    Can you run: >>> pykx.q(‘l s.k_’) If that still fails check >>> import os >>> os.environ[“QHOME”] ‘/home/user/folder/venv/lib/python3.10/site-packages/pykx/lib’ >>> os.listdir(os.environ[“QHOME”]) [‘write.q’, ‘m64arm’, ‘p.q’, ‘l64arm’, ‘l64’, ‘kxic.k’, ‘_update_marker’, ‘bq.q_’, ‘csvutil.q’, ‘kurl.q_’, ‘q.k’, ‘s.k_’, ‘w64’, ‘qlog.q_’, ‘m64’, ‘objstor.q_’, ‘read.q’, ‘rest.q_’, ‘kurl.sidecar.q_’] PyKX 1.6.0 includes a utility for inspecting these common areas pykx.util.debug_environment(detailed=True)

Page 9 of 21