Message Boards Message Boards

0
|
8804 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Get[] function file paths for .nb in the cloud?

Posted 8 years ago

Background Information: I'm still trying to find the best way to feed data from back-end files built with Wolfram Language to a front-end user interface also built with Wolfram Language. At first I thought that writing it all as one file was the best approach; however, at about 1800 lines of code and growing, it has become unwieldy and hard to debug. So then I turned to deploying APIFunctions that would serve as the back-end suppliers of data. That worked except that the data would lose some of the Wolfram formatting when transferred. In particular, math expressions would revert back to their unformatted form and images would transfer as super-long strings.

Current Question: I recently stumbled upon the Get[] function. It seems to do exactly what I need, evaluate the Wolfram expressions in one file, and send them to the calling file (hopefully in exactly the same native Wolfram format). So far all my tests have been good, but they have all gotten data from deployed APIFunctions. According to the docs, Get[] should be able to open a .nb file, evaluate its expressions, and return data. Is it possible to use Get[] to open a .nb file that is stored (not deployed) in my Wolfram Cloud account? If so, how can I determine the file path?

If this isn't possible, is there something similar in the Wolfram Language to the "include" statement of other languages, where one file (or part of a file) is read into the main block of code before execution?

Thanks in advance,

Mark Greenberg

PS. I'm a beginner with the Wolfram Language, so please type your answers slowly. ; )

POSTED BY: Mark Greenberg
2 Replies

It sounds like you the function you want is CloudGet, the analog of the local function `Get' for the cloud. Supposing you have created a Wolfram Language package that includes the code you want executed when it is retrieved called code.wl. Firstly you should upload it to the cloud. Then you load that code using: CloudGet[CloudObject["https://develop.wolframcloud.com/objects/<username>/<file>.wl"]] where you substitute your user name and the name of the file. (Note I'm assuming the file is stored in your home directory in the cloud. If not you will need to include the proper path after the user name). Calling the above from your desktop will get the file from the cloud, evaluate all the code contained and return the final result.

POSTED BY: Andrew de Laix
Posted 8 years ago

Thanks for your replay, Andrew. In my newness to the realm of Wolfram, I have to ask some basic questions to understand what you are saying.

Supposing you have created a Wolfram Language package...

I've seen the option to create a package, but I don't know what a package is. So far, all the files that I have created have been notebooks, .nb files. I don't see an option in the Wolfram Desktop environment (version 11) to save what I have been working on as a package.

Firstly you should upload it to the cloud....

As far as I can tell, the cloud is the only place I can save what I create in the Wolfram Language. The File menu only has "Save...", which automatically saves what I have open to the cloud, and "Save to the Cloud...", which gives me a dialog box for saving to the cloud. Once a file is in the cloud, I can download it to my local machine.

CloudGet[CloudObject...

So far I have come to think of "cloud objects" and "files saved in cloud storage" as two different things, "cloud objects" being somehow deployed and assigned a special ID. Do I have to deploy the file or package first before using CloudGet?

Sorry for all the confusion. I'll get there eventually, but there is a lot to learn before I do.

Thanks,

Mark Greenberg

POSTED BY: Mark Greenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract