[10:09:04] Do you mean this error in Z10697? : https://tools-static.wmflabs.org/bridgebot/44db812b/file_63097.jpg [10:09:48] I have a hard time understanding results like that. Does anyone here have a trick to translate all those Zids to labels? [10:42:14] I started this page today https://www.wikifunctions.org/wiki/Wikifunctions:Python_implementations [11:16:16] I added https://phabricator.wikimedia.org/T343593 but it affects both Javascript and Python, so we might want to move it to a more general page? (re @dpriskorn: I started this page today https://www.wikifunctions.org/wiki/Wikifunctions:Python_implementations [11:16:16] Please help list the quirks an...) [11:52:26] New bug found T371484 which affect lookup in wikidata from a python implementation [13:00:16] chatgpt suggests that python WF implementations are so restricted that they cannot make http requests at all. I really hope that is not the case. See https://phabricator.wikimedia.org/T371484#10031784 [13:02:51] "chatgpt suggests" usually means it's a lie [13:02:51] in this case, however, it is correct (re @dpriskorn: chatgpt suggests that python WF implementations are so restricted that they cannot make http requests at all. I really hope that...) [13:11:33] I'm really surprised. That severely limits the usefulness of WF. Is it intentional? If yes, is it going to be possible in the future? (re @mahir256: "chatgpt suggests" usually means it's a lie [13:11:33] in this case, however, it is correct) [13:12:29] I will focus on making functions that accept Wikidata JSON instead like chatgpt suggested because that seems to work fine 😀 [13:13:57] this is the closest mention I can find, though Denny has made this clearer in prior public discussions on the subject (re @vrandecic: Right now your shouldn't be able to make any outside requests. If you are, please let us know immediately.) [13:26:01] I can verify that any requests using python is impossible. The not very user-friendly error I get is documented here: T371484 (re @vrandecic: Right now your shouldn't be able to make any outside requests. If you are, please let us know immediately.) [13:34:49] I opened T371497 [14:03:32] I'm surprised, chatgpt can now generate WF json with Zobjects.It seems the chatgpt developers are aware of the project and supports it, like they do for Wikidata 🤩 : https://tools-static.wmflabs.org/bridgebot/c594fa5a/file_63107.jpg [14:19:13] New ticket T371503 [14:34:45] Can someone help debug this? See Z18320 : https://tools-static.wmflabs.org/bridgebot/71482002/file_63108.jpg [14:49:41] a couple of things: [14:49:42] - the JSON argument is too long, probably, so it might be getting cut off (leading to the invalid JSON error) [14:49:43] - you weren't indexing into the JSON output of Special:EntityData properly [14:49:45] - I changed the function to only expect a single entity (that is, instead of {"entities":{"l3286":{...}}}, it expects just {...} as input now) (re @dpriskorn: Can someone help debug this? See Z18320) [15:04:20] It is correct and intentional; the sandboxing and security model strictly prohibit network access from Python and JS. There is a not-quite-implemented feature that will let us make callbacks to the function orchestrator, which has far fewer security restrictions, and, at some point, we will probably allow at least some HTTP requests from the orchestrator. With these two features, Python implementations could (in a [15:04:20] roundabout way) make HTTP requests. I think that it will still be somewhat restricted, though; one of the fears about this system is that arbitrary HTTP requests could invite abuse. (re @dpriskorn: 8:11 AM <+wm-bb> I'm really surprised. That severely limits the usefulness of WF. Is it intentional? If yes, is it going to be possible in the future?) [15:05:13] Hah! This is very cool (re @dpriskorn: I'm surprised, chatgpt can now generate WF json with Zobjects.It seems the chatgpt developers are aware of the project and supports it, like they do for Wikidata 🤩) [15:20:25] I added a bit more context on https://phabricator.wikimedia.org/T371484 [16:20:41] https://www.irccloud.com/pastebin/JWl7A55w/ [16:21:07] It looks like you got Z18320 working. I notice that the implementation returns strings when there's a problem. For future reference, if you want to create an error, you can do things like [16:21:07] ``` [16:21:09] if something_bad_happened: [16:21:10] raise Exception('error string')``` [16:21:12] and you'll get a `Z5/Error` in the metadata. [16:21:23] (sorry, copypasted the message from the link) [16:21:57] ^ The above is not well-documented, my fault 😬 [16:22:26] no problem, thanks for your help :) [16:22:34] <3 [17:01:56] I'll try to help document, as I go by 😃 (re @wmtelegram_bot: ^ The above is not well-documented, my fault 😬) [17:05:43] Fantastic! Thanks for chipping in. 🙏 [17:05:43] Do you know the max char input limitation? (re @mahir256: a couple of things: [17:05:45] - the JSON argument is too long, probably, so it might be getting cut off (leading to the invalid JSON error...) [17:06:48] Thank you for the clarifications and comment on the ticket. (re @wmtelegram_bot: I added a bit more context on https://phabricator.wikimedia.org/T371484) [17:15:03] ✅ switched back to booleans and it now raises errors properly. The test pass. 🥳 (re @Sannita: It looks like you got Z18320 working. I notice that the implementation returns strings when there's a problem. For future refere...) [17:27:25] [[Wikifunctions:Determinism]] is a draft about it; the fact that functions should be pure (which rules out web requests) is also mentioned in [[Wikifunctions:About]] (re @mahir256: this is the closest mention I can find, though Denny has made this clearer in prior public discussions on the subject) [17:41:35] Is it possible to create new functions in Wikifunctions? [17:41:52] Another question: has anyone experimented with wikitext parsing in Wikifunctions? 😁 [17:42:06] That's what Dennis is doing, yes (re @harej: Is it possible to create new functions in Wikifunctions?) [17:42:20] yes (re @harej: Is it possible to create new functions in Wikifunctions?) [17:42:32] How? Nothing on the main page or sidebar tells you how [17:43:39] Wikidata there is a sidebar link "create new item" [17:43:56] On the main page I see a link to "suggest a function" [17:44:40] Instructions on how to create functions are buried half-way down to page under a vague "introduction" link [17:44:54] https://www.wikifunctions.org/w/index.php?title=Special:CreateObject&zid=Z8 [17:45:03] this needs to be addressed in fact (re @harej: Instructions on how to create functions are buried half-way down to page under a vague "introduction" link) [17:47:11] How do we go about it? Project chat? (re @Sannita: this needs to be addressed in fact) [17:49:24] This about functions being pure reminds me of Q19597382. Very hard core programming going on there 😅 (re @lucaswerkmeister: [[Wikifunctions:Determinism]] is a draft about it; the fact that functions should be pure (which rules out web requests) is also...) [17:49:28] yep (re @dpriskorn: How do we go about it? Project chat?) [17:49:33] I would say project chat [17:49:42] and that's a community decision now, if you ask me [17:52:18] We should make tell user to thoroughly search for existing functions before creating a new one though. [17:55:34] I am trying to submit an implementation and I am getting an error saying Invalid JSON. This doesn't tell me what the problem is or how to fix it. [17:59:03] Also regarding this purity, while it certainly have advantages from both a security and design perspective it also comes with limitations. E.g. functions for everything fluctuating like gas prices, stock prices, electrical prices, etc. is impossible to implement. [17:59:04] E.g. I would like to make a function that looks up the current gas price in Sweden using an API and then calculate the cost of a travel by car. It should also be able to find cities based on string input and to geolocation e.g. Stockholm -> Q1754 -> coordinates -> distance. [17:59:06] So then would ideally only have to input: [17:59:07] from city, to city, fuel type and the consumption of fuel per 10 km (a total of 4 inputs) (re @lucaswerkmeister: [[Wikifunctions:Determinism]] is a draft about it; the fact that functions should be pure (which rules out web requests) is also...) [18:12:37] I just read [[Wikifunctions:About]]. [18:12:37] I really like the vision/goals expressed in it, but it is not a good description of the current Wikifunctions IMO. [18:12:39] I suggest renaming it to Wikifunctions:Vision or something like that and copying parts over that describe the projects current state and link to the vision. [18:12:40] WDYT? [18:38:44] I just read [[Wikifunctions:Determinism]]. It makes a lot of sense to be honest. I added a section about prices. [18:46:03] One open question is how to handle things like geolocation? Maybe we should avoid it by telling users to input QIDs to such functions, which then lookup coordinates in Wikidata and output the distance based on a calculation between 2 coordinates. [18:46:03] Alternatively the user input 2 coordinates directly. [19:07:20] I created Z18331 but it has a failing test and I fail to find the cause. [19:08:06] try editing the implementation, maybe it will rerun the failing test and get it to pass (re @vrandecic: Hm, that one stayed in the cache for a bit. Once I made an edit, it got unstuck) [19:09:31] we should document this also for new editors somewhere. (re @mahir256: try editing the implementation, maybe it will rerun the failing test and get it to pass) [19:12:58] I found the bug now, it did dash prefix stripping on the value 💩 (re @mahir256: try editing the implementation, maybe it will rerun the failing test and get it to pass) [19:29:25] I tried publishing this implementation but get the error "invalid json" [19:29:25] I'm guessing it has to do with the regex string. [19:29:27] ``` [19:29:28] def Z18336(Z18336K1): [19:29:30] # strip prefix dash [19:29:31] string = str(Z18336K1)[1:].strip() [19:29:33] if '-' in string and string.startswith('L'): [19:29:34] # cheching form or sense id [19:29:36] pattern = r'(L\d+-[FS]\d+)' [19:29:37] import re [19:29:39] if re.search(pattern, string): [19:29:40] return True [19:29:42] return False [19:29:43] else: [19:29:45] if not string.startswith(('L', 'P', 'Q')) or not string[1:].isdigit(): [19:29:46] return False [19:29:48] else: [19:29:49] return True``` [19:32:04] no your code works fine locally (re @dpriskorn: I tried publishing this implementation but get the error "invalid json" [19:32:04] I'm guessing it has to do with the regex string. [19:32:06] def Z18...) [19:43:24] In Z10696, I used a different definition of valid, "Checks if a given string is a valid Qid in Wikidata i.e. if it resolves to an item" (re @wikilinksbot: Z18336 – is valid Wikidata entity identifier? [19:43:24] Z18336K1 – is valid Wikidata entity identifier?) [21:05:58] Yes, I suggest renaming that one. It's more about resolvning than validating the ID as is based on a format. (re @Jan_ainali: In Z10696, I used a different definition of valid, "Checks if a given string is a valid Qid in Wikidata i.e. if it resolves to a...) [21:09:17] My idea is that to save the code in a JSON string it has to be serialized to not break the JSON syntax. That serialization seems buggy and my guess is that the regex is the cause. (re @mahir256: no your code works fine locally) [21:20:36] created T371561 (re @dpriskorn: I tried publishing this implementation but get the error "invalid json" [21:20:37] I'm guessing it has to do with the regex string. [21:20:39] def Z18...) [22:31:09] The dirty secret is that none of our functions are actually pure. They all depend on the eternally-changing global state of stored ZObjects. That said, we can generally ignore that detail and treat lots of functions as pure. There are of course objects which are intrinsically impure if modeled as functions: getting a "true" random number (i.e., not from a seed but from something like /dev/random), making an HTTP request, [22:31:09] etc. There are different ways to handle this. Some functional programming languages use the type calculus for it: a randomly-generated number can't be a regular numeric type but a special random number type. It's also possible just to accept that some functions aren't deterministic or pure. It's not clear how we'll handle this yet. (re @dpriskorn: Also regarding this purity, while it certainly have advantages from both a [22:31:09] security and design perspective it also comes with limitations. E.g. functions for everything fluctuating like gas prices, stock prices, electrical prices, etc. is impossible to implement.) [22:31:34] I don't get any errors when I run this implementation locally. (re @dpriskorn: I'm guessing it has to do with the regex string.) [22:34:55] I'm curious about the "invalid JSON" stuff. I'd be surprised if we were running up against any content size limits, but there may be some effective limits in the backend that we just haven't tested. I don't see any reason that this code should break anything when saved as an implementation (the `\d` should just get escaped when we serialize the JSON). Can you make a task with precise reproduction instructions? [22:49:34] See the task above. It includes reproduction steps and the full response from MW also. [22:49:34] I'm happy to provide more details if necessary. (re @wmtelegram_bot: I'm curious about the "invalid JSON" stuff. I'd be surprised if we were running up against any content size limits, but ...) [23:03:02] Ah, sorry, didn't see the task number. I'm looking. [23:41:33] Okay, there's some info in the task: https://phabricator.wikimedia.org/T371561 . For now, you have to double-escape those sequences while we work through JSON-stringification problems in various parts of the stack 😓 . So `r'(L\\d+-[FS]\\d+)'` should work. [23:41:50] Thanks for finding this!!!! [23:42:03] I was really surprised; I thought we had tested for this, but I guess not.