Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(activity): activities for the 3rd workshop #62

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"github_url": "https://github.com/pyopensci/lessons",
"footer_start": ["code_of_conduct", "copyright"],
"footer_end": [],
"navigation_with_keys": False,
}

html_context = {
Expand Down
Binary file added images/github/github-fork-repo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 88 additions & 15 deletions publish-share-code/activity-1-share-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,70 @@ kernelspec:
# Share Your Code Activities


## Activity 1 - install a package from GitHub

:::{note}

If you are comfortable using Git and GitHub and have a Python package in mind, check the package's repo on GitHub or GitLab to ensure that the package structure and source code are correct.

If you are working on this during a pyOpenSci workshop, you can use the package you created in our workshop!
If you are comfortable using Git and GitHub and have a Python package already on GitHub, you can use that package for this activity. Otherwise, we suggest that you fork the [pyospackage repository](https://github.com/pyOpenSci/pyosPackage) for this activity!

If not, you can start with the [pyospackage repository](https://github.com/pyOpenSci/pyosPackage).
:::

## Activity 1: Install a package from GitHub

1. Create & activate a Python environment that you wish to use for this activity.

`python -m venv pyosworkshop`

If you are working on a Mac, A Linux machine or in the GitHub codespace that we setup, you can activate the environment using:

`source pyosworkshop/bin/activate`

If you are using Windows, use:

`.\pyosworkshop\Scripts\activate`


2. After activating the environment, [install the pyosPackage package](install-github) in that repository using `pip`.

```bash
pip install git+https://github.com/pyopensci/pyospackage.git
```

+++

## Activity 2: Fork the repo and install a package from your fork

Above, you installed a package from a pyOpenSci-owned GitHub repo.
Now, you will do the same thing, but instead, you will install your package from a fork that you own of the pro package.

Because you own this fork, you can make any changes you wish to the code.

1. Fork the [pyospackage repository](https://github.com/pyOpenSci/pyosPackage) on GitHub.
2. This repository has a GitHub Codespace setup with VS Code. Optional: after you fork the repository, you can use a GitHub codespace to modify the source code and package name (if you wish).
3. Install the package in that repository from your fork.


:::{figure} ../images/github/github-fork-repo.gif
---
alt: "alt here."
name: fork-github-repo
width: 700px
---

To begin, fork the pyospackage GitHub repository.
:::

Now, you can install the same package into the same environment using the command below. IMPORTANT: be sure to modify the URL of the repo to represent your FORK.

```bash
pip install git+https://github.com/YOUR-GITHUB-USERNAME-HERE/pyospackage.git
```

+++

## Activity 2: Connect your Python package repo to Zenodo
## Activity 3: Connect your Python package repo to Zenodo

In this activity, you will connect the GitHub repository containing a Python package to [Zenodo to create a DOI (Digital Object Identifier)](zenodo) for your code. This will allow others to cite your work and give credit to contributors.
In this activity, you will connect the GitHub repository that you just forked containing a Python package to [Zenodo to create a DOI (Digital Object Identifier)](zenodo) for your code. This will allow others to cite your work and give credit to contributors.

If you completed **Activity 1** above, you should already have a GitHub repository set up. Now, we’ll take it a step further by setting up a citation for your project using Zenodo.
If you completed **Activity 2** above, you should already have a GitHub repository set up. Now, we’ll take it a step further by setting up a citation for your project using Zenodo.

### Steps to Connect Your Repository to Zenodo
### Steps to connect your repository to Zenodo

1. **Connect Your Repository to Zenodo**
- Go to [Zenodo](https://zenodo.org/) and log in using your GitHub account.
Expand All @@ -47,15 +86,49 @@ If you completed **Activity 1** above, you should already have a GitHub reposito

2. **Create a Release**
- In your GitHub repository, navigate to the **Releases** section. Click on **Draft a new release**.
- Assign an available version number to the release (e.g., `v1.0.0`) and provide a title and description.
- Assign the release an available version number (e.g., `v1.0.0`) and provide a title and description.
- Click on **Publish release**. This action will trigger Zenodo to generate a DOI for your code.

3. **Get the DOI Badge and Add It to Your README File**
- Go back to Zenodo and find your newly generated DOI under your repository's name in the **Upload** section.

IMPORTANT: When completing this step, be sure to grab the Zenodo badge for "all versions" rather than the most recent version.

Zenodo will provide a badge code that you can copy. Go back to your GitHub repository, open your `README.md` file, and paste the DOI badge code at the top or in a dedicated section like **Citing this Code**.

+++

## Activity 4: Rename your package and create a new release

In this activity, you will further develop the Python package you have worked on (or the package you forked above).

1. Rename the package by updating both the `pyproject.toml` file and the package directory found within the `src/package-name`

2. If you wish, add a new function to the package using the codespace provided in the repository. Commit your changes before moving on to the next step.

3. Create a new release of the package on GitHub.

4. Check out the Zenodo landing page for your package. Do you see the new release there?

:::{note}
Note: the new release may take 5-10 minutes to process.
:::


+++
## Activity 5: Add a CITATION.cff file to your repo

1. Visit [this website](https://citation-file-format.github.io/cff-initializer-javascript/#/start) which has a tool that allows you to create and validate a new CITATION.cff file.
2. Using the tool above, add appropriate citation information using the citation you created for your package using Zenodo.
3. Add the CITATION.cff file to your new GitHub repository! If you aren't comfortable using GitHub and git you can do this on GitHub using the GitHub add file button!

+++

## Activity 6: Publish your package on test PyPI

For this activity, you will practice publishing your package to test-pypi. We will follow the [guidance provided in this lesson](https://www.pyopensci.org/python-package-guide/tutorials/publish-pypi.html).

- Zenodo will provide a badge code that you can copy. Go back to your GitHub repository, open your `README.md` file, and paste the DOI badge code at the top or in a dedicated section like **Citing this Code**.
To be successful in this activity, you will need to have

By completing this activity, you’ve taken an important step in making your code citable and accessible to others. Properly citing code encourages transparency and reproducibility, helping others build upon your work with confidence.
1. A [test-PyPI account setup](https://test.pypi.org/account/register/)
2. A unique package name. Don't try to use pyospackage. We suggest renaming your package to something unique like `pyospackage-yourGitHubUserName`
2 changes: 1 addition & 1 deletion publish-share-code/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Publish your Code <publish-code>
:maxdepth: 2


Share your Code <activity-1-share-code>
Activities: Share your Code <activity-1-share-code>

:::

Expand Down
3 changes: 2 additions & 1 deletion publish-share-code/share-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Sharing your code online using [open licenses](https://www.pyopensci.org/python-

When your code is hosted on a shared platform, others can easily download, install, and use it, making it more accessible and useful to the broader community. Additionally, you can set up proper citations for your code, giving contributors and yourself credit for the work and promoting transparency. [Learn more about setting up citation in our lesson on citing code.](cite-your-code)

### Different ways to share code
## Different ways to share code

There are several ways to share code.
1. You can post your code to an online repository like GitHub or GitLab.
Expand All @@ -47,6 +47,7 @@ Version control systems (like Git) are fundamental to collaborative coding. Thes

Using hosting platforms like GitHub and GitLab helps you manage your code and provides a welcoming environment for contributors to get involved and contribute back to your project.

(install-github)=
## Install software directly from GitHub

Once you have turned your code into a Python package and shared it on GitHub, multiple ways exist to make it directly installable. One simple approach is to install your package directly from GitHub using `pip`.
Expand Down