DocumentationUse casesDevelopers

PyCafe for developers

Communication with users

Users of your software will most likely communicate with you through GitHub issues or other text-based communication channels. Often, code examples are shown in these communications, and more often than not, these code examples are not fully runnable. This can make it difficult to understand the problem the user is facing. By asking the user to provide a minimal, reproducible example that runs on PyCafe, you can focus on solving the problem, instead of trying to reproduce it.

GitHub issue templates

A good way to ask users to provide a minimal, reproducible example is by using GitHub issue templates. You can create a GitHub issue template file in your repository, which will be used as a template when users create a new issue. You can use this template to ask users to provide a minimal, reproducible example that runs on PyCafe.

Example 1: streamlit-aggrid

The streamlit-aggrid repository has a GitHub issue template that will ask users that open new issues to provide a minimal, reproducible example that runs on PyCafe.

...
**live code**
Please include a functional example. You may use the excellent [py.cafe](https://py.cafe/) to share your code.
...

This makes it much easier for the maintainers of the streamlit-aggrid project to understand the problem the user is facing and to help them solve it, possibly answering the question with another PyCafe example.

Example 2: Vizro

vizro

Vizro, a dashboarding solution developed at McKinsey, also uses a GitHub issue template that asks users to provide a minimal, reproducible example that runs on PyCafe.

...
      description: Provide steps to reproduce this bug. You can also [use a PyCafe link](https://py.cafe/snippet/vizro/v1) to share your example.
...

Deploying and testing build artifacts

Often, during nightly runs, or when a PR is opened, one of the byproducts is a Python wheel that contains the potential new version of your library. Although tests should be run on the CI, it can be useful to deploy this wheel to PyCafe to test it in a real-world scenario, or to debug or visually inspect the changes made in the new version.

Instead of needing to check out the the branch on your local computer, or manually installing the wheel, you can easily install the wheel into a fresh PyCafe environment by entering the wheel URL into your requirements file.

Installing wheels from GitHub actions artifacts

For instance, Panel uses a nighty build to create a wheel that is uploaded to using the upload-artifact action. This wheel can be installed in a PyCafe environment by adding the following line to the requirements.txt file:

# requirements.txt
https://py.cafe/gh/artifact/holoviz/panel/2021154790/panel-1.5.2-py3-none-any.whl

See API for more information on how to use this feature.

Installing wheels from S3

Streamlit uploads its wheels to an S3 bucket. These wheels can be installed in a PyCafe environment by adding the following line to the requirements.txt file:

# requirements.txt
https://core-previews.s3-us-west-2.amazonaws.com/pr-9625/streamlit-1.39.0-py2.py3-none-any.whl

The PyCafe interface provides an UI to generate snippet links, under the ‘Share’ button. However, in automated workflows, it can be useful to generate these links programmatically.

See /docs/api for more information on how to generate snippet links programmatically.

Insert snippets into a PR workflow

Ideally, you would want to generate a link that points to a PyCafe snippet which gives you a full environment to test the wheel. It would be convenient to have a GitHub action or bot that generates this link and posts it as a comment on the PR. This way, you can easily test the wheel by clicking on the link in the PR.

We have not yet developed a solution for this. If you are interested in this feature, please contact us or join us on discord.

In the meantime, you could print out a url in a GitHub action.