| 17:12 | ludwa6[m] | shout-out to symbioquine : thanks for the help on this JupyterLite thing, mate: farmos.discourse.group/t/share-your-jupy |
| 17:12 | ludwa6[m] | am still kinda stuck, if you want to chat it out here, might be faster. |
| 17:26 | symbioquine[m] | Sure ludwa6 |
| 17:26 | symbioquine[m] | It's a little hard for me to go off just that screenshot... |
| 17:27 | ludwa6[m] | yeah, i figured. can i just send you my instance, somehow? |
| 17:27 | symbioquine[m] | Are you willing to share the notebook itself? (By saving, then clicking the "file" menu and "download") |
| 17:28 | ludwa6[m] | ah! of course. dunno if that has the CSV file, but i guess it don't matter. comin up |
| 17:28 | 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 |
| 17:28 | symbioquine[m] | I don't think I need the CSV file to start with. |
| 17:28 | ludwa6[m] | ah, right; it's got some API creds in it. will email directly |
| 17:31 | ludwa6[m] | file sent |
| 17:32 | ludwa6[m] | it's mostly just don's code, with mine (yours) inserted around code block 6 |
| 17:34 | 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 |
| 17:35 | symbioquine[m] | I guess I do need the CROPS.csv file (or a sample of it) |
| 17:36 | * | posted a file: (26KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 17:39 | * | uploaded an image: (253KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 17:40 | ludwa6[m] | ? so you are on an earlier version...? |
| 17:41 | symbioquine[m] | I switched to the `io.StringIO` strategy;... (full message at libera.ems.host/_matrix/media/r0/downloa) |
| 17:41 | * | = Pandas version 1.3.5 |
| 17:41 | * | Numpy version 1.21.4 |
| 17:42 | 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. |
| 17:42 | symbioquine[m] | I kind of doubt it's caused by the version difference since those are highly stable libraries. (in my understanding) |
| 17:43 | symbioquine[m] | What browser/version are you using? |
| 17:43 | ludwa6[m] | ok, so... I tried your alternate method. fails in a different way: |
| 17:44 | ludwa6[m] | ---------------------------------------------------------------------------... (full message at libera.ems.host/_matrix/media/r0/downloa) |
| 17:44 | symbioquine[m] | Oh, yeah I did `import io` as you can see in my screenshot. |
| 17:44 | ludwa6[m] | Chrome logo |
| 17:44 | ludwa6[m] | Google Chrome |
| 17:44 | ludwa6[m] | Nearly up to date! Relaunch Chrome to finish updating. Incognito windows won't reopen. |
| 17:44 | ludwa6[m] | Version 98.0.4758.80 (Official Build) (x86_64) |
| 17:45 | ludwa6[m] | should i reboot browser? i don't have any incognito windows going on |
| 17:46 | ludwa6[m] | got a bunch of state i'd rather not lose... But a worthwhile sacrifice, if it'll help. ? |
| 17:46 | symbioquine[m] | ludwa6[m]: No, don't worry about that for now. Just try again with the `import io` statement like I did. |
| 17:49 | ludwa6[m] | symbioquine[m]: i *think* i did it right... But still: |
| 17:49 | symbioquine[m] | Or you could import my version whole; gist.github.com/symbioquine/24121598e517 |
| 17:49 | ludwa6[m] | ---------------------------------------------------------------------------... (full message at libera.ems.host/_matrix/media/r0/downloa) |
| 17:50 | symbioquine[m] | Hmmm, interesting |
| 17:51 | 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. |
| 17:53 | ludwa6[m] | just tried your gist in chrome, no joy. will try ffx |
| 17:53 | 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) |
| 17:55 | symbioquine[m] | ludwa6[m]: Awesome, looking forward to the result... |
| 17:56 | 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... |
| 18:01 | ludwa6[m] | symbioquine[m]: yes |
| 18:01 | ludwa6[m] | and, sorry to say: same 5hit, different browser: |
| 18:01 | ludwa6[m] | ---------------------------------------------------------------------------... (full message at libera.ems.host/_matrix/media/r0/downloa) |
| 18:02 | ludwa6[m] | it's on a different line, of course, since i was running your 3 code blocks verbatim, per your gist |
| 18:02 | * | uploaded an image: (24KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 18:02 | ludwa6[m] | yep: i just pushed the arrow up to UL |
| 18:02 | ludwa6[m] | and i got CROPS.csv, right there in the same directory as the .ipynb |
| 18:03 | ludwa6[m] | man: this browser Local Storage stuff is deep voodoo |
| 18:04 | mstenta[m] | i wonder what the file size limits are too... |
| 18:04 | ludwa6[m] | tiny file. like 25kb this |
| 18:05 | mstenta[m] | if we did implement www.drupal.org/project/jupyterlite/issue i wonder if it would potentially crash someone's browser if there are too many files |
| 18:05 | mstenta[m] | (just thinking ahead) |
| 18:05 | symbioquine[m] | Yeah, it's quite a bit smaller than the KML files I was testing with. |
| 18:05 | symbioquine[m] | mstenta[m]: I doubt it, since it probably would skip the IDB storage and talk to the server instead... |
| 18:08 | mstenta[m] | I suppose it depends on how JupyterLite works? I believe it currently loads everything it finds in a directory into localstorage |
| 18:08 | symbioquine[m] | ludwa6[m]: It does take some time to wrap one's head around, but there's actually no magic in it; |
| 18:08 | * | uploaded an image: (285KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 18:08 | 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? |
| 18:08 | 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 |
| 18:09 | symbioquine[m] | symbioquine[m]: The files are stored as text key/values and that `get_contents` function just looks up the specified file... |
| 18:10 | mstenta[m] | ooh! oh that's good - didn't know that |
| 18:10 | 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? |
| 18:10 | symbioquine[m] | ludwa6[m]: I believe so |
| 18:12 | symbioquine[m] | symbioquine[m]: or the same thing in Chrome; |
| 18:12 | * | uploaded an image: (495KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 18:13 | symbioquine[m] | ludwa6: Maybe you can try inspecting the JupyterLite page and see if that shows up similarly for you? |
| 18:15 | ludwa6[m] | symbioquine[m]: ? which? you mean edgecollective.io/jupyterlite/lab/index.. ? |
| 18:15 | ludwa6[m] | that's the one i'm using |
| 18:16 | ludwa6[m] | it is authorised to access my vdl.farmos.dev instance |
| 18:16 | * | uploaded an image: (60KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 18:17 | symbioquine[m] | Open the developer tools while on the `edgecollective.io/jupyterlite/lab/index.` page, then navigate to the "Application" tab, "IndexedDB", "JupyterLite Storage", "files". |
| 18:17 | symbioquine[m] | then see if the "CROPS.csv" shows up as a key |
| 18:18 | symbioquine[m] | <symbioquine[m]> "image.png" <- like in this screenshot |
| 18:18 | 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? |
| 18:19 | symbioquine[m] | mstenta[m]: Could be |
| 18:19 | symbioquine[m] | I can try on the edgecollective.io one... |
| 18:19 | mstenta[m] | oh or you're just having trouble getting a file to show up? sorry only loosely following here :-) |
| 18:19 | mstenta[m] | don't mind me :-) |
| 18:19 | 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 :) |
| 18:23 | 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" |
| 18:23 | mstenta[m] | Storage tab actually |
| 18:25 | ludwa6[m] | mstenta[m]: got it. 3 items, including CROPS.csv |
| 18:26 | 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... |
| 18:27 | * | uploaded an image: (1094KiB) < libera.ems.host/_matrix/media/r0/downloa > |
| 18:27 | symbioquine[m] | mstenta[m]: In Firefox |
| 18:27 | 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/" ? |
| 18:28 | symbioquine[m] | ludwa6[m]: Sounds like it :) |
| 18:28 | symbioquine[m] | If you uploaded files to a subdirectory, you'd need to modify the path you specify accordingly. |
| 18:30 | symbioquine[m] | I suppose it's not obvious that the `get_contents` function effectively takes an absolute path within the browser storage :) |
| 18:30 | ludwa6[m] | well, it's in the same directory as the .ipynb, so i thought path is implicit |
| 18:30 | symbioquine[m] | Yeah, unfortunately not |
| 18:31 | ludwa6[m] | anyway: i prefixed with "farmos/" which failed, and then "/farmos/" ... Same fail: NameError: name 'get_contents' is not defined |
| 18:31 | ludwa6[m] | i mean, same fail in both cases. different than that subscript error we were getting, so maybe this is progress? |
| 18:31 | symbioquine[m] | Sounds like perhaps you didn't run that first cell that defines the `get_contents` function...? |
| 18:33 | 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) |
| 18:34 | ludwa6[m] | symbioquine[m]: no, i did that.... but now, i dunno: maybe i gotta restart kernel, clear outputs, try again |
| 18:34 | ludwa6[m] | damn: back to that old error: TypeError: 'NoneType' object is not subscriptable |
| 18:35 | 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. |
| 18:35 | symbioquine[m] | ludwa6[m]: Can I see the current state of the notebook? |
| 18:35 | ludwa6[m] | wha... hold the phone! went back to chrome and made that path change, and... it worked! |
| 18:36 | symbioquine[m] | ludwa6[m]: Cool, I think that was the root cause all along :) |
| 18:36 | 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. |
| 18:36 | ludwa6[m] | warnings.warn(msg) |
| 18:36 | symbioquine[m] | along with maybe some gotchas about imports and not re-running the cells in the right order... |
| 18:37 | symbioquine[m] | That warning shouldn't be a problem. |
| 18:37 | symbioquine[m] | I get that too and it still works |
| 18:37 | ludwa6[m] | symbioquine[m]: geez, what a stupid n00b mistake to be stumbling over all this time |
| 18:37 | symbioquine[m] | In Firefox I think it would work if you remove the initial "/" that you added. |
| 18:38 | symbioquine[m] | * would work too if you |
| 18:39 | 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. |
| 18:39 | ludwa6[m] | symbioquine[m]: ! right you are, mate! was sure i had tried it with & w/o leading slash. |
| 18:39 | symbioquine[m] | ludwa6[m]: I think you did, but only in conjunction with the state where the `get_contents` function wasn't defined. |
| 18:41 | 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 :-) |
| 18:41 | symbioquine[m] | Haha, no worries :) |
| 18:42 | ludwa6[m] | Seriously tho: deep voodoo, this stuff. You are truly a wizard to get it working. |
| 18:45 | 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. |
| 18:46 | symbioquine[m] | I admire your perseverance in toughing through that troubleshooting even when it feels like magic :) |
| 18:52 | ludwa6[m] | <symbioquine[m]> "I admire your perseverance in..." <- heh -i am nothing if not stubborn |
| 18:53 | 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 |
| 18:55 | 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 :) |