Group Abstract Group Abstract

Message Boards Message Boards

Is it possible to publish to the cloud using custom packages and custom stylesheets?

Posted 1 year ago

I have 100+ notebooks which all depend on on a custom style sheet and one or more custom packages. Is it possible to share these on the cloud so that they have access to the packages and stylesheet?

POSTED BY: Steven Hatton
Posted 8 days ago

Steven,

That is an excellent and common question for users transitioning large-scale Mathematica projects to the Wolfram Cloud.

Yes, it is absolutely possible to publish notebooks to the Cloud while ensuring they have access to custom packages and custom stylesheets.

Deploying Custom Packages (.m Files)

For your notebooks to successfully call functions from your custom packages (that is, using Needs["MyPackage"]), those packages must be accessible in the Cloud file system.

Method 1: Deploying to the Root Directory

The most direct way to make packages available is to upload them to a specific location in your Cloud account's file system, then use the CloudConnect mechanism.

a) Upload the Package

Upload your .m package files to your main Cloud directory (usually cloud://) or a dedicated subdirectory (for example, cloud:///Packages/)

b) Referencing in Notebooks

In the notebook you plan to deploy, make sure the Needs call correctly points to the Cloud location. The Wolfram Language automatically searches your root cloud directory and its subdirectories when using Needs.

For example, if you place your package in cloud:///MyPackages/MyPackage.m your notebook should simply use:

Needs["MyPackage`"]

c) Deployment

When you deploy your 100+ notebooks, they will automatically look for the package in your cloud file system.

Method 2 - Best Practice: Using CloudPublish or CloudDeploy with Dependencies

When using CloudDeploy or CloudPublish, you can include the package files directly in the deployment, ensuring they are bundled with the application:

CloudDeploy[
  "MyNotebook.nb",
  Permissions -> "Public",
  Dependencies -> {"cloud:///MyPackages/MyPackage1.m", "cloud:///MyPackages/MyPackage2.m"}
]

Deploying Custom Stylesheets (.nbc or .css Files)

A. For Stylesheet Files (.nbc/.nbss)

a) Upload the Stylesheet

Upload your custom stylesheet file to your Cloud account

cloud:///Styles/MyCustomStyle.nbc

b) Cloud Deployment

When you save your notebook in the Desktop app, go to Format > Style Sheet and select Other... to link the notebook to your custom stylesheet file on the Cloud.

c) Save and Deploy

Save the notebook and then deploy it to the Cloud. As long as the Cloud link to the stylesheet remains, the deployed notebook will load with that style.

B. For Web Elements (HTML/CSS

If your custom stylesheet is a standard CSS file intended for a WebPage deployment, you must:

a) Upload the CSS:

Upload the .css file (example, MyStyle.css) to the Cloud.

b) Reference in Code

In your Wolfram Language code, you would typically use Import or directly reference the URL/path to load the style or insert it into a HTML structure.

For example, using CloudGet on the CSS file and inserting it into the HTML generated by your application.

In summary, the key to managing dependencies in the Cloud is to upload all supporting files (packages, stylesheets) to your Cloud file system and ensure your notebooks use Cloud paths (cloud:///...) to reference them.

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