This snippets in this subdirectory are for workbench users who directly use the workspace bucket.
The instructions are identical for all of the snippets collections. See CONTRIBUTING for the details. If you are new to git
, please see the example commands there.
- Write your snippet of code in your preferred language, R or Python.
- Try to make your snippet consistent with other snippets in this collection.
- Choose a good prefix and suffix for your snippet file name.
- See the names of the other files for examples.
- The file name helps users decide whether the snippet will be useful to them.
- Put some comments at the top of your snippet to explain its purpose and any assumptions.
- After you are happy with your new snippet, port it to the other language or file a GitHub issue asking for help from someone else to do this.
- If your snippet has any inputs or parameters, add default values for those parameters to both
snippets_setup.R
andsnippets_setup.py
so that your snippet will work as-is. - Update r_gcs_snippets_menu_config.yml and py_gcs_snippets_menu_config.yml to add your snippet where ever you would like it to be displayed within the menu.
- Send your pull request!
Don't like these conventions? We can change them! This is just a starting point. Keep in mind we'll need to reflect those changes in the auto-generation script described in the next section.
The instructions are identical for all of the snippets collections. See CONTRIBUTING for the details.
To test individual snippets, the best thing to do is copy and paste them into a notebook on the workbench.
If the smoke tests are run from the workbench environment and there are no obvious bugs in the snippets, they will run start-to-finish without error. (This won't necessarily catch all bugs, but its a good start.)
- The script to auto-generate the Jupyter Snippets Menu configuration also emits both
r_gcs_snippets_menu_config_smoke_test.R
andpy_gcs_snippets_menu_config_smoke_test.py
. - Those scripts each include, respectively, all the R Cloud Storage snippets and all the Python Cloud Storage snippets.
- Additional configuration needed for the smoke tests can be defined in r_gcs_snippets_menu_config.smoke_test_setup and py_gcs_snippets_menu_config.smoke_test_setup, respectively. Update it as needed.
After opening a notebook in the production workbench environment, upload these smoke test files into Jupyter and then execute the following code from the Jupyter terminal or a Python notebook in the same directory. They will emit "Smoke test complete!" when they have completed successfully.
To run the R Cloud Storage snippets smoke tests:
%%bash
Rscript r_gcs_snippets_menu_config_smoke_test.R # There will be output, but there should be no errors.
To run the Python Cloud Storage snippets smoke tests:
%%bash
python3 py_gcs_snippets_menu_config_smoke_test.py # There will be output, but there should be no errors.
The instructions are identical for all of the snippets collections. See CONTRIBUTING for the details.