[12:12:33] | <ludwa6[m]> | shout-out to symbioquine : thanks for the help on this JupyterLite thing, mate: https://farmos.discourse.group/t/share-your-jupyterlite-examples/1134/16... |
[12:12:53] | <ludwa6[m]> | am still kinda stuck, if you want to chat it out here, might be faster. |
[12:26:21] | <symbioquine[m]> | Sure ludwa6 |
[12:26:55] | <symbioquine[m]> | It's a little hard for me to go off just that screenshot... |
[12:27:17] | <ludwa6[m]> | yeah, i figured. can i just send you my instance, somehow? |
[12:27:31] | <symbioquine[m]> | Are you willing to share the notebook itself? (By saving, then clicking the "file" menu and "download") |
[12:28:01] | <ludwa6[m]> | ah! of course. dunno if that has the CSV file, but i guess it don't matter. comin up |
[12:28:11] | <symbioquine[m]> | If you want it to be private (I won't share it with anyone else) you can email it to symbioquine@gmail.com |
[12:28:31] | <symbioquine[m]> | I don't think I need the CSV file to start with. |
[12:28:47] | <ludwa6[m]> | ah, right; it's got some API creds in it. will email directly |
[12:31:54] | <ludwa6[m]> | file sent |
[12:32:17] | <ludwa6[m]> | it's mostly just don's code, with mine (yours) inserted around code block 6 |
[12:34:19] | <ludwa6[m]> | block 5 is the full "magic spell" (was in fact truncated before, which i fixed) and block 6 is the call that fails on line 2 |
[12:35:34] | <symbioquine[m]> | I guess I do need the CROPS.csv file (or a sample of it) |
[12:36:05] | <ludwa6[m]> | ACTION posted a file: (26KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/XPPIIJcIvPQ... > |
[12:39:51] | <symbioquine[m]> | ACTION uploaded an image: (253KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/ebapbguMyUD... > |
[12:40:56] | <ludwa6[m]> | ? so you are on an earlier version...? |
[12:41:30] | <symbioquine[m]> | I switched to the `io.StringIO` strategy;... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/6f973595ba...) |
[12:41:33] | <ludwa6[m]> | ACTION = Pandas version 1.3.5 |
[12:41:33] | <ludwa6[m]> | ACTION Numpy version 1.21.4 |
[12:42:12] | <symbioquine[m]> | I copied them to a new notebook so that I could safely run it without accidentally invoking the cells below the point of interest. |
[12:42:47] | <symbioquine[m]> | I kind of doubt it's caused by the version difference since those are highly stable libraries. (in my understanding) |
[12:43:38] | <symbioquine[m]> | What browser/version are you using? |
[12:43:48] | <ludwa6[m]> | ok, so... I tried your alternate method. fails in a different way: |
[12:44:10] | <ludwa6[m]> | ---------------------------------------------------------------------------... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/684b0ee01b...) |
[12:44:29] | <symbioquine[m]> | Oh, yeah I did `import io` as you can see in my screenshot. |
[12:44:47] | <ludwa6[m]> | Chrome logo |
[12:44:47] | <ludwa6[m]> | Google Chrome |
[12:44:47] | <ludwa6[m]> | Nearly up to date! Relaunch Chrome to finish updating. Incognito windows won't reopen. |
[12:44:47] | <ludwa6[m]> | Version 98.0.4758.80 (Official Build) (x86_64) |
[12:45:58] | <ludwa6[m]> | should i reboot browser? i don't have any incognito windows going on |
[12:46:28] | <ludwa6[m]> | got a bunch of state i'd rather not lose... But a worthwhile sacrifice, if it'll help. ? |
[12:46:44] | <symbioquine[m]> | ludwa6[m]: No, don't worry about that for now. Just try again with the `import io` statement like I did. |
[12:49:39] | <ludwa6[m]> | symbioquine[m]: i *think* i did it right... But still: |
[12:49:39] | <symbioquine[m]> | Or you could import my version whole; https://gist.github.com/symbioquine/24121598e517360cc2924e37315fb116 |
[12:49:41] | <ludwa6[m]> | ---------------------------------------------------------------------------... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/25d67ddf15...) |
[12:50:03] | <symbioquine[m]> | Hmmm, interesting |
[12:51:29] | <symbioquine[m]> | Do you have Firefox? Maybe you can open firefox to test with? You'd need to upload my example and `CROPS.csv` since Firefox has a separate in-browser storage. |
[12:53:15] | <ludwa6[m]> | just tried your gist in chrome, no joy. will try ffx |
[12:53:54] | <symbioquine[m]> | It's working in Chrome 93 for me. I kind of doubt it's the browser at this point, but I'll try updating Chrome (I don't use it much so that's why it's out of date) |
[12:55:11] | <symbioquine[m]> | ludwa6[m]: Awesome, looking forward to the result... |
[12:56:44] | <symbioquine[m]> | Just to be sure, you are uploading the `CROPS.csv` through your browser right? I haven't tested whether that `get_contents` function works for files which are already existing from the server... |
[13:01:04] | <ludwa6[m]> | symbioquine[m]: yes |
[13:01:22] | <ludwa6[m]> | and, sorry to say: same 5hit, different browser: |
[13:01:24] | <ludwa6[m]> | ---------------------------------------------------------------------------... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/2b0e2adb16...) |
[13:02:09] | <ludwa6[m]> | it's on a different line, of course, since i was running your 3 code blocks verbatim, per your gist |
[13:02:09] | <symbioquine[m]> | ACTION uploaded an image: (24KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/QbtWDFELHsA... > |
[13:02:27] | <ludwa6[m]> | yep: i just pushed the arrow up to UL |
[13:02:48] | <ludwa6[m]> | and i got CROPS.csv, right there in the same directory as the .ipynb |
[13:03:28] | <ludwa6[m]> | man: this browser Local Storage stuff is deep voodoo |
[13:04:12] | <mstenta[m]> | i wonder what the file size limits are too... |
[13:04:27] | <ludwa6[m]> | tiny file. like 25kb this |
[13:05:07] | <mstenta[m]> | if we did implement https://www.drupal.org/project/jupyterlite/issues/3264048 i wonder if it would potentially crash someone's browser if there are too many files |
[13:05:23] | <mstenta[m]> | (just thinking ahead) |
[13:05:24] | <symbioquine[m]> | Yeah, it's quite a bit smaller than the KML files I was testing with. |
[13:05:58] | <symbioquine[m]> | mstenta[m]: I doubt it, since it probably would skip the IDB storage and talk to the server instead... |
[13:08:11] | <mstenta[m]> | I suppose it depends on how JupyterLite works? I believe it currently loads everything it finds in a directory into localstorage |
[13:08:23] | <symbioquine[m]> | ludwa6[m]: It does take some time to wrap one's head around, but there's actually no magic in it; |
[13:08:29] | <symbioquine[m]> | ACTION uploaded an image: (285KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/ARbQBjUaaJs... > |
[13:08:38] | <ludwa6[m]> | i kinda hate to bring it up, since we're all about FOSS, but i gotta ask: in terms of getting to working prototype of a zero-install .ipynb notebook in browser as API interface to farmOS, what to y'all think of the gColab alternative? |
[13:08:42] | <mstenta[m]> | eg: I noticed that if you add a file in the filesystem it is NOT automatically added in the UI - you need to clear localstorage in order for it to show up |
[13:09:47] | <symbioquine[m]> | symbioquine[m]: The files are stored as text key/values and that `get_contents` function just looks up the specified file... |
[13:10:08] | <mstenta[m]> | ooh! oh that's good - didn't know that |
[13:10:34] | <ludwa6[m]> | mstenta[m]: ? if you upload thru that up arrow icon in JupyterLite interface, it should just work without any clearing of localstorage, right? |
[13:10:53] | <symbioquine[m]> | ludwa6[m]: I believe so |
[13:12:46] | <symbioquine[m]> | symbioquine[m]: or the same thing in Chrome; |
[13:12:53] | <symbioquine[m]> | ACTION uploaded an image: (495KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/RHccIJNVhTX... > |
[13:13:55] | <symbioquine[m]> | ludwa6: Maybe you can try inspecting the JupyterLite page and see if that shows up similarly for you? |
[13:15:21] | <ludwa6[m]> | symbioquine[m]: ? which? you mean https://edgecollective.io/jupyterlite/lab/index.html. ? |
[13:15:34] | <ludwa6[m]> | that's the one i'm using |
[13:16:02] | <ludwa6[m]> | it is authorised to access my vdl.farmos.dev instance |
[13:16:43] | <symbioquine[m]> | ACTION uploaded an image: (60KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/zUlbDdJRLhd... > |
[13:17:38] | <symbioquine[m]> | Open the developer tools while on the `https://edgecollective.io/jupyterlite/lab/index.html` page, then navigate to the "Application" tab, "IndexedDB", "JupyterLite Storage", "files". |
[13:17:53] | <symbioquine[m]> | then see if the "CROPS.csv" shows up as a key |
[13:18:03] | <symbioquine[m]> | <symbioquine[m]> "image.png" <- like in this screenshot |
[13:18:35] | <mstenta[m]> | symbioquine: out of curiousity - did you test on your own JupyterLite instance? I believe the edgecollective.io one was cloned from their demo instance - but maybe there have been fixes recently that are creating a difference here? |
[13:19:03] | <symbioquine[m]> | mstenta[m]: Could be |
[13:19:09] | <symbioquine[m]> | I can try on the edgecollective.io one... |
[13:19:14] | <mstenta[m]> | oh or you're just having trouble getting a file to show up? sorry only loosely following here :-) |
[13:19:21] | <mstenta[m]> | don't mind me :-) |
[13:19:57] | <symbioquine[m]> | It works for me in `Chrome 98.0.4758.102` btw, so it's probably not a difference between Chrome 93 and Chrome 98 :) |
[13:23:04] | <ludwa6[m]> | <symbioquine[m]> "Open the developer tools while..." <- sorry... i'm kinda lost. have switched to firefox, opened developer tools: Application tab... but it just says "No Service Worker found" |
[13:23:56] | <mstenta[m]> | Storage tab actually |
[13:25:14] | <ludwa6[m]> | mstenta[m]: got it. 3 items, including CROPS.csv |
[13:26:33] | <symbioquine[m]> | ludwa6[m]: Sorry that was confusing. The instructions I typed out were for Chrome, but you can see how to get there in either browser from my screenshots... |
[13:27:02] | <symbioquine[m]> | ACTION uploaded an image: (1094KiB) < https://libera.ems.host/_matrix/media/r0/download/matrix.org/bkQoGtzfwuJ... > |
[13:27:45] | <symbioquine[m]> | mstenta[m]: In Firefox |
[13:27:53] | <ludwa6[m]> | symbioquine[m]: no matter: in the end, key/value pair looks right. except it has "farmos/CROPS.CSV" as the path. Should i try prefixing the filename with "farmos/" ? |
[13:28:24] | <symbioquine[m]> | ludwa6[m]: Sounds like it :) |
[13:28:56] | <symbioquine[m]> | If you uploaded files to a subdirectory, you'd need to modify the path you specify accordingly. |
[13:30:15] | <symbioquine[m]> | I suppose it's not obvious that the `get_contents` function effectively takes an absolute path within the browser storage :) |
[13:30:41] | <ludwa6[m]> | well, it's in the same directory as the .ipynb, so i thought path is implicit |
[13:30:53] | <symbioquine[m]> | Yeah, unfortunately not |
[13:31:17] | <ludwa6[m]> | anyway: i prefixed with "farmos/" which failed, and then "/farmos/" ... Same fail: NameError: name 'get_contents' is not defined |
[13:31:46] | <ludwa6[m]> | i mean, same fail in both cases. different than that subscript error we were getting, so maybe this is progress? |
[13:31:47] | <symbioquine[m]> | Sounds like perhaps you didn't run that first cell that defines the `get_contents` function...? |
[13:33:43] | <symbioquine[m]> | If you watch my GIF you'll see that I clicked in each of the cells to run them (unfortunately I used the <ctrl>-<enter> key combo so it isn't super obvious, but that's what I did) |
[13:34:15] | <ludwa6[m]> | symbioquine[m]: no, i did that.... but now, i dunno: maybe i gotta restart kernel, clear outputs, try again |
[13:34:28] | <ludwa6[m]> | damn: back to that old error: TypeError: 'NoneType' object is not subscriptable |
[13:35:14] | <symbioquine[m]> | You could also use the ⏩ button to rerun the whole notebook in order but it's slower because it also restarts the kernel. |
[13:35:36] | <symbioquine[m]> | ludwa6[m]: Can I see the current state of the notebook? |
[13:35:59] | <ludwa6[m]> | wha... hold the phone! went back to chrome and made that path change, and... it worked! |
[13:36:27] | <symbioquine[m]> | ludwa6[m]: Cool, I think that was the root cause all along :) |
[13:36:48] | <ludwa6[m]> | maybe cuz firefox was giving me this library warning (but you sahad said not to worry, so i didn't): /lib/python3.9/site-packages/pandas/compat/__init__.py:124: UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError. |
[13:36:48] | <ludwa6[m]> | warnings.warn(msg) |
[13:36:55] | <symbioquine[m]> | along with maybe some gotchas about imports and not re-running the cells in the right order... |
[13:37:09] | <symbioquine[m]> | That warning shouldn't be a problem. |
[13:37:20] | <symbioquine[m]> | I get that too and it still works |
[13:37:35] | <ludwa6[m]> | symbioquine[m]: geez, what a stupid n00b mistake to be stumbling over all this time |
[13:37:59] | <symbioquine[m]> | In Firefox I think it would work if you remove the initial "/" that you added. |
[13:38:16] | <symbioquine[m]> | * would work too if you |
[13:39:08] | <symbioquine[m]> | That `get_contents` function isn't very smart about what paths it will accept. It needs the path to exactly match the key/filename. |
[13:39:11] | <ludwa6[m]> | symbioquine[m]: ! right you are, mate! was sure i had tried it with & w/o leading slash. |
[13:39:45] | <symbioquine[m]> | ludwa6[m]: I think you did, but only in conjunction with the state where the `get_contents` function wasn't defined. |
[13:41:12] | <ludwa6[m]> | Phew: long haul, but worth it -at least for me. As for you, symbioquine , your reward awaits you in neaven, if there be any justice in this world :-) |
[13:41:32] | <symbioquine[m]> | Haha, no worries :) |
[13:42:07] | <ludwa6[m]> | Seriously tho: deep voodoo, this stuff. You are truly a wizard to get it working. |
[13:45:15] | <symbioquine[m]> | It's good to find these rough edges early. A lot of these things are a bit of eye-rolling programming mistakes, but do serve to emphasize that JupyterLite - and scripting in general - aren't going to be a magic bullet for many users. |
[13:46:44] | <symbioquine[m]> | I admire your perseverance in toughing through that troubleshooting even when it feels like magic :) |
[13:52:09] | <ludwa6[m]> | <symbioquine[m]> "I admire your perseverance in..." <- heh -i am nothing if not stubborn |
[13:53:39] | <ludwa6[m]> | <symbioquine[m]> "It's good to find these rough..." <- tried to post the lesson learned to Discourse, but that's no substitute for documentation. May be obvious to most, but i think the right-click to get ref to absolute filepath is worth documenting in the eventual HowTo |
[13:55:04] | <symbioquine[m]> | ludwa6[m]: Thanks for doing that! And great suggestion with the right click and "copy path" strategy. That'll avoid a lot of headaches in the future :) |