Create a new Materials Commons project

This example demonstrates creating a new Materials Commons project from a Jupyter notebook. To try running it locally, download the notebook from here.

To install the necessary dependencies (requires Python 3):

pip install materials-commons-cli

For this notebook, you must configure mc beforehand:

 mc remote --add user@domain.edu https://materialscommons.org/api
 mc remote --set-default user@domain.edu https://materialscommons.org/api

Notes:

File Transfer

These examples demonstrate the mixed use of Python with shell commands (! ...) to make use of the Materials Commons CLI in a Jupyter notebook.

Setup for upload examples:

This creates a directory and writes some files used in the upload examples.

Upload one file

By default, files that already exist will be skipped

Upload multiple files

Upload files and directories, recursively

Uploading the notebook itself / use of "upload_as"

It is possible to upload a notebook, from within the notebook itself. To do so, we can use the --upload-as option which allows uploading files that do not exist in the local cloned project directory. The following cells demonstrate getting the notebook's name, nb_name, and then uploading the notebook itself to the Materials Commons project. It is placed in a "notebooks" directory. Note that it uploads the last saved version of the notebook, not the current state.

_Note: Getting the notebook file path from os.path.join(os.getcwd(), nb_name) may not work in all cases_

Setup for download examples

This removes the existing local files and directories to demonstrate downloading from Materials Commons.

Download one file

By default, files that already exist will be skipped

Download multiple files

Download files and directories, recursively

Download with different name

Using Globus file transfer

Monitor transfer status

Finish the transfer

Example cleanup

The delete_project call will delete a project on Materials Commons.

Notes: