rocuinneagain
Forum Replies Created
-
If you pad out t2 ensuring it has a row for every col1 value then you’ll get what you want:
q)t1:([] col1:`a`b`c`d;col2:1 2 3 8;col3:11 22 33 88) q)t2:([] col1:`a`a`b`c;col4:4 5 6 7;col5:44 55 66 77)
q)(t2 uj select distinct col1 from t1 where not col1 in t2`col1) lj `col1 xkey t1 col1 col4 col5 col2 col3 ------------------------ a 4 44 1 11 a 5 55 1 11 b 6 66 2 22 c 7 77 3 33 d 8 88
- This reply was modified 21 hours, 32 minutes ago by rocuinneagain.
- This reply was modified 21 hours, 32 minutes ago by rocuinneagain.
- This reply was modified 21 hours, 28 minutes ago by rocuinneagain.
-
rocuinneagain
MemberJanuary 10, 2025 at 10:35 am in reply to: Error when using in Jupyter : ”licence error: embedq”A PyKX enabled license must be used.
Issued from: https://kx.com/kdb-insights-personal-edition-license-download/
(Not from: https://kx.com/kdb-personal-edition-download/ )
-
Since release 4.0.0 the ML toolkit can use either PyKX or embedPy
https://github.com/KxSystems/ml/releases
Both PyKX and embedPy cannot run in the same process so installing and using only one is best.
To make PyKX available to q processes follow: https://code.kx.com/pykx/3.0/pykx-under-q/intro.html#install
The command to run is:
python -c "import pykx;pykx.install_into_QHOME()"
-
The error ’embedq’ means you license does not have the needed flag to enable PyKX.
To get an Insights and PyKX enabled license go to: Download kdb Insights | KX
-
What version of PyKX are you using?
In a q session can you use the new license?
Does it have the needed flags for PyKX?
q)`insights.lib.embedq`insights.lib.pykx in `$" " vs .z.l 4 // Should return 11b
When you run import pykx as kx did you paste the full output? PyKX does try to include what is specifically wrong with a license.
- This reply was modified 2 weeks, 1 day ago by rocuinneagain.
- This reply was modified 2 weeks, 1 day ago by rocuinneagain.
- This reply was modified 2 weeks, 1 day ago by rocuinneagain.
-
rocuinneagain
MemberJanuary 6, 2025 at 3:10 pm in reply to: Multiprocessing with pykx hanging on trying to load db from diskWhat OS are you using?
PyKX does not support multiprocessing on Windows.
See also: Multithreaded Execution – PyKX
-
Both work perfectly fine. For someone new to Linux I would probably say try Ubuntu – if you have issues you’ll find more threads/tutorials online for it.
Windows Subsystem for Linux (WSL) is a great option to have access to Linux locally on your Windows machine.
- Install WSL | Microsoft Learn
- Ubuntu 22.04.5 LTS – Free download and install on Windows | Microsoft Store
- This reply was modified 1 month ago by rocuinneagain.
-
Hi,
What version of PyKX do you have installed?
You need at least 3.0.0 to use that syntax.
pip install pykx==3.0.1
-
/: each-right is what you want https://code.kx.com/q/ref/maps/#each-left-and-each-right
q).test.ex.t1:{[data] data};
q).test.ex.t2:{[data] data};
q).test.ex ./:((`t1;1);(`t2;1))
1 1
- This reply was modified 1 month, 2 weeks ago by rocuinneagain.
-
embedPy operates in a q first manner so you’d have to load your .p file and then call a q statement outside to do the assignment:
https://github.com/KxSystems/embedPy/tree/master/docs
q)func:.p.get[`func]
PyKX is the most flexible interface as it allows you do mix q first and Python first code in the same project
Python first assign a python function to a q variable
>>> kx.q['func'] = func
q first assign a python function to a q variable:
https://code.kx.com/pykx/2.5/pykx-under-q/intro.html#function-calls
q)func:.pykx.get[`func]
- This reply was modified 3 months, 1 week ago by rocuinneagain.
- This reply was modified 3 months, 1 week ago by rocuinneagain.
- This reply was modified 3 months, 1 week ago by rocuinneagain.
- This reply was modified 3 months, 1 week ago by rocuinneagain.
- This reply was modified 3 months, 1 week ago by rocuinneagain.
- This reply was modified 3 months, 1 week ago by rocuinneagain.
- This reply was modified 3 months, 1 week ago by rocuinneagain.
- This reply was modified 3 months, 1 week ago by megan_mcp.
- This reply was modified 3 months, 1 week ago by megan_mcp.
- This reply was modified 3 months, 1 week ago by megan_mcp.
- This reply was modified 3 months, 1 week ago by megan_mcp.
- This reply was modified 2 months ago by supportelearningwp-com.
- This reply was modified 2 months ago by supportelearningwp-com.
-
rocuinneagain
MemberOctober 5, 2024 at 11:54 am in reply to: How to run os commands in new KX Developer instanceYour other post asks about Windows.’ls’ and ‘pwd’ are Linux commands and will not work on Windows.
Try \dir which is a valid command in a Windows command prompt.
-
For example code use backslash to leave it as a multi line comment so those wishing to use this as a library can load the script without it running the example every time.
https://code.kx.com/q/basics/syntax/#comments
See example: https://github.com/KxSystems/kdb-tick/blob/master/tick.q#L50
- This reply was modified 3 months, 3 weeks ago by rocuinneagain.
- This reply was modified 2 months ago by supportelearningwp-com.
code.kx.com
Syntax | Basics | kdb+ and q documentation - kdb+ and q documentation
Syntax of the q programming language
-
The question is vague on what you are trying to do and how (no example code etc.)
Below is an example which when run results in:
HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello
Java can decompress the data which kdb+ compressed with .Q.gz without issue:
import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.zip.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.lang.String; import com.kx.c; public class Main { public static String decompress(final byte[] bytes) throws IOException { if (bytes == null || bytes.length == 0) { return ""; } try (final GZIPInputStream ungzip = new GZIPInputStream(new ByteArrayInputStream(bytes))) { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final byte[] data = new byte[8192]; int nRead; while ((nRead = ungzip.read(data)) != -1) { out.write(data, 0, nRead); } return out.toString(); } } public static void main(String[] args) { c c = null; Object result = null; byte[] bytes = null; try { c = new c("localhost", 5001); String query="`byte$.Q.gz(9;400#"Hello")"; result = c.k(query); bytes = ((byte[]) result); System.out.println(decompress(bytes)); } catch (Exception e){ System.err.println(e.toString()); } } }
- This reply was modified 3 months, 3 weeks ago by rocuinneagain.
- This reply was modified 3 months, 3 weeks ago by rocuinneagain.
- This reply was modified 3 months, 3 weeks ago by rocuinneagain.
- This reply was modified 3 months, 3 weeks ago by rocuinneagain.
- This reply was modified 3 months, 3 weeks ago by rocuinneagain.
- This reply was modified 3 months, 3 weeks ago by rocuinneagain.
- This reply was modified 2 months ago by supportelearningwp-com.
- This reply was modified 2 months ago by supportelearningwp-com.
-
Do you have warnings supressed?
The output of the failed import should be like:
PYKX_GC=True python test.py
<frozen importlib._bootstrap>:241: PyKXWarning: Failed to initialize PyKX successfully with the following error: Captured output from initialization attempt:
'2025.01.10T12:11:03.276 licence error: k4.lic
License location used:
Traceback (most recent call last):
File "/home/rocuinneagain/q/test.py", line 1, in <module>
import pykx as kx
File "/home/rocuinneagain/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pykx/__init__.py", line 32, in <module>
from . import core
File "pykx/core.pyx", line 394, in init pykx.core
pykx.exceptions.PyKXException: Early garbage collection requires a valid q license.Your output is missing the first line.
Do you have the QLIC environment variable set?
You put your license in /home/rr/q/l64/
A more standard location would be one level higher at /home/rr/q/
Can you start python with PYKX_UNLICENSED=True python
Then run:
>>> import pykx as kx
>>> kx.util.debug_environment()And share the output here? It will give more information on your environment.
-
You likely downloaded from: https://kx.com/kdb-personal-edition-download/
But it does not have the Insights and PyKX features enabled.
You nee to get a license from: https://kx.com/kdb-insights-personal-edition-license-download/