--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/netlogo-users/44ec2abb-95db-4d86-b53d-2accf03aab37n%40googlegroups.com.
Hi Shir-May,
I'm the one who made HubNet Web and the conversion guide for it.
Thank you for your interest in the project.
is there a way to export simulation files - after it's finished?
In the desktop version - I exported CSV files, but as far as I understand I can't do this in the web version. (Is that right?)
You can export files in NetLogo Web, just not using language
primitives like `file-open`. Code that is running on web pages
isn't allowed to talk directly to the user's file system—you can
imagine what a problem it would be if any web page you went to
could read all the files on your computer. But there are language
extensions available in NetLogo Web that enable you to handle
files in ways that web browsers allow. Unfortunately (and maybe
ironically), the Web extension isn't one of them, as it isn't
implemented in NetLogo Web. (The `http-req` extension fills a
similar purpose, but isn't API-compatible with desktop's Web
extension, and won't help in this situation.)
The main way you should save a file from NetLogo Web is by using the `send-to`
extension, which is available in both desktop NetLogo and
NetLogo Web. A very simple example of its usage would be:
`send-to:file "my-favorite-fruits.txt"
"grapes\napples\noranges\nbananas"`.
Also, you mentioned CSV files. If it's helpful to you, the CSV
extension is available in NetLogo Web. However, its
`to-file` and `from-file` primitives are not implemented on the
web.
Finally, it sounds like you're having some difficulties with
narrowcast/client-specific plots in HubNet Web. The canonical
example of narrowcast plots is the Oil Cartel model, which you
might find helpful as a demonstration of how to do it.
Regardless, if you e-mail me the '.hnw.json' file for your model,
I can help with getting your histogram to work. After the
experience of converting all 39 of the HubNet models in the
NetLogo Models Library to run in HubNet Web, my bet is that I can
figure this one out, too.
Jason Bertsche
Hi everyone — thank you all for the responses, and thank you Jason for the very detailed reply 🙏🏻.
That cleared up a lot for me, and I have a few more things:
Plots: I did manage to get my narrowcast/client-specific plots working, but they make the simulation very slow. I’ll email you my .hnw.json so you can take a quick look.
Exporting data: I’ll try the send-to:file approach for saving the CSV strings from my model. Thanks for confirming that this is the right path on the web.
If possible, I’d love to ask for a 5-minute Zoom, just to sanity-check my setup while you skim the .hnw.json. Totally understand if that’s not doable 🙏🏻. I just don’t want to bother you (Jason) with too many emails or long back-and-forth in the forum.(😅 if maybe a quick zoom could resolve it faster.)
Also, a couple of quick clarifications about file export in NetLogo Web:
File size & reliability: Are there practical limits (or browser gotchas) for send-to:file (e.g., tens of MB)? Would you recommend chunking/partitioning long “run” logs?
Filenames & UX: Is there a recommended pattern to ensure the browser keeps the suggested name (like logger_world_init_data_YYYYMMDD_HHMMSS.csv), or should I expect a rename prompt in some browsers?
Multiple saves per session: Do browsers require a fresh user gesture for each send-to:file save, or can two saves (INIT and RUN) happen back-to-back from one button click?
Cloud upload from model: Is there any recommended way to upload directly to a server (e.g., Google Apps Script → Drive) from NetLogo Web? I know the web: extension isn’t implemented — is http-req viable for POSTing raw CSV, or is the best practice to just use send-to:file and let the wrapper/page handle uploads?
Thanks again for all your help and for HubNet Web itself — it’s awesome. 🙏🏻
I’ll send the .hnw.json right away. :)
Best,
Shir-May
File size & reliability: Are there practical limits (or browser gotchas) for send-to:file (e.g., tens of MB)? Would you recommend chunking/partitioning long “run” logs?
Chunking is probably a good idea if your files get particularly
large. NetLogo Web ought to be able to handle larger files, but,
in my experience, asking it to save a single string that's a
megabyte in size or more will lead to unsteady performance.
Filenames & UX: Is there a recommended pattern to ensure the browser keeps the suggested name (like logger_world_init_data_YYYYMMDD_HHMMSS.csv), or should I expect a rename prompt in some browsers?
Both Firefox and Chrome seem to respect the file name that I provide to `send-to:file`, so I think that you're fine on that front.
Multiple saves per session: Do browsers require a fresh user gesture for each send-to:file save, or can two saves (INIT and RUN) happen back-to-back from one button click?
That's up to the browser. Firefox allows two downloads from the same user action, but Chrome only allows one before popping up a dialog asking if you want to allow multiple downloads. I haven't tested on Safari, but I would also expect them to only allow one.
Cloud upload from model: Is there any recommended way to upload directly to a server (e.g., Google Apps Script → Drive) from NetLogo Web? I know the web: extension isn’t implemented — is http-req viable for POSTing raw CSV, or is the best practice to just use send-to:file and let the wrapper/page handle uploads?
If I wanted to gather logs in NetLogo Web, yeah, the first thing I
would try would be `http-req:post`. The syntax is `http-req:post
url body contentType` (all arguments are strings).
I'll follow up about the other things.
Jason Bertsche