Skip to content

Commit

Permalink
✅ Ready to clone and code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigoula authored and github-actions[bot] committed Mar 7, 2024
1 parent 550dac0 commit cf58715
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 42 deletions.
8 changes: 4 additions & 4 deletions .github/rename_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ echo "Description: $description";

echo "Renaming project..."

original_author="akatief"
original_name="template_workshop"
original_urlname="template-workshop"
original_description="Awesome template_workshop created by akatief"
original_author="ibigoula"
original_name="ukp_template_workshop"
original_urlname="UKP_Template_Workshop"
original_description="Awesome ukp_template_workshop created by ibigoula"
# Iterate over all files in the repository
git ls-files | while read -r filename; do
# Exclude .github/workflows/rename_project.yml from renaming
Expand Down
1 change: 0 additions & 1 deletion .github/template.yml

This file was deleted.

10 changes: 5 additions & 5 deletions ABOUT_THIS_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ It includes:
- 📃 Documentation structure using [mkdocs](http://www.mkdocs.org)
- 🧪 Testing structure using [pytest](https://docs.pytest.org/en/latest/)
- ✅ Code linting using [pylint](https://pypi.org/project/pylint/)
- 🎯 Entry points to execute your program using `python -m <template_workshop>` with basic CLI argument parsing.
- 🔄 Continuous integration using [Github Actions](https://github.com/akatief/template-workshop/actions) with jobs to check, lint and test your project.
- 🎯 Entry points to execute your program using `python -m <ukp_template_workshop>` with basic CLI argument parsing.
- 🔄 Continuous integration using [Github Actions](https://github.com/ibigoula/UKP_Template_Workshop/actions) with jobs to check, lint and test your project.

Are there any changes you'd like to request? Feel free to fork and open a pull request!

Expand Down Expand Up @@ -46,7 +46,7 @@ Lets take a look at the structure of this template:
├───docs # Auto-generated documentation
│ index.md # Landing page of docs
├───template_workshop # The main python package for the project
├───ukp_template_workshop # The main python package for the project
│ base.py # The base module for the project
│ cli.py # Defines CLI instructions
│ __init__.py # This tells Python that this is a package
Expand All @@ -63,7 +63,7 @@ Lets take a look at the structure of this template:

### Where should I add new stuff ?

You should create new files and subpackages inside template_workshop and implement your functionalities there. Remember to add what you write to `__init__.py` so that the imports work smoothly. Take a look at `base.py` and `__init__.py` to understand how it works
You should create new files and subpackages inside ukp_template_workshop and implement your functionalities there. Remember to add what you write to `__init__.py` so that the imports work smoothly. Take a look at `base.py` and `__init__.py` to understand how it works

### Why is `requirements.txt` empty ?

Expand All @@ -79,7 +79,7 @@ This file lists all the requirements for testing and development. Use it to sepa

### What is the `.github` folder?

It contains [GitHub Actions](https://docs.github.com/en/actions) that are executed automatically when pushing your code. You can see results for your repository [here](https://github.com/akatief/template-workshop/actions).
It contains [GitHub Actions](https://docs.github.com/en/actions) that are executed automatically when pushing your code. You can see results for your repository [here](https://github.com/ibigoula/UKP_Template_Workshop/actions).

### What does the linter workflow do?

Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
</p>

# Template Workshop
[![License](https://img.shields.io/github/license/akatief/template-workshop)](https://opensource.org/licenses/Apache-2.0)
[![License](https://img.shields.io/github/license/ibigoula/UKP_Template_Workshop)](https://opensource.org/licenses/Apache-2.0)
[![Python Versions](https://img.shields.io/badge/Python-3.9-blue.svg?style=flat&logo=python&logoColor=white)](https://www.python.org/)
[![CI](https://github.com/akatief/template-workshop/actions/workflows/main.yml/badge.svg)](https://github.com/akatief/template-workshop/actions/workflows/main.yml)
[![CI](https://github.com/ibigoula/UKP_Template_Workshop/actions/workflows/main.yml/badge.svg)](https://github.com/ibigoula/UKP_Template_Workshop/actions/workflows/main.yml)

Welcome! In this workshop you'll learn how to set up your next research project using the official [UKP Template](https://github.com/UKPLab/ukp-project-template). This repo is actually a copy of the original template with a few changes to the README, everything else is the same.

Expand All @@ -20,7 +20,7 @@ Let's get started!

First thing first, you need to have a copy of this repository on your own GitHub account as well as on your PC.

1. Set the repository up in your personal GitHub account by clicking **[Use this template](https://github.com/akatief/template-workshop/generate)**. It's important you set the repository as **public**, otherwise the following tasks won't work correctly.
1. Set the repository up in your personal GitHub account by clicking **[Use this template](https://github.com/ibigoula/UKP_Template_Workshop/generate)**. It's important you set the repository as **public**, otherwise the following tasks won't work correctly.
2. Wait until the first run of CI finishes. Github Actions will commit to your new repo with a "✅ Ready to clone and code" message.
3. Open the repo folder and prepare a virtual environment:
```bash
Expand All @@ -40,23 +40,23 @@ Write a class to compute the Fibonacci sequence in an optimal way. Then, impleme

This is the expected command line usage you should implement:
```bash
template_workshop n # Will return fib(n)
ukp_template_workshop n # Will return fib(n)
```

### What to change

You need to add your code to the following files:

- `template_workshop/__init__.py`: Defines the content of the template_workshop package. It's important to configure it properly to have a cleaner `import` structure in your code. Use it to avoid ugly [absolute imports](https://www.geeksforgeeks.org/absolute-and-relative-imports-in-python/).
- `template_workshop/cli.py`: Defines how to handle CLI arguments and calls the Fibonacci class.
- `template_workshop/fibonacci.py`: Contains the Fibonacci class.
- `ukp_template_workshop/__init__.py`: Defines the content of the ukp_template_workshop package. It's important to configure it properly to have a cleaner `import` structure in your code. Use it to avoid ugly [absolute imports](https://www.geeksforgeeks.org/absolute-and-relative-imports-in-python/).
- `ukp_template_workshop/cli.py`: Defines how to handle CLI arguments and calls the Fibonacci class.
- `ukp_template_workshop/fibonacci.py`: Contains the Fibonacci class.

## 🩺 Task 2 - Implementing tests

Testing is an integral part of development that ensures your code works by covering all edge cases. The percentage of your lines that are checked by tests is called *coverage*. In an ideal testing scenario you would run at every single line in your code least once. A test suite is a collection of simple functions that call different parts of your code and make some assertions. For example, here is the content of `test_base.py`, a suite for testing the (rather useless) `BaseClass` included in the package. As you can see, it runs every possible use case of BaseClass.

```py
from template_workshop import BaseClass
from ukp_template_workshop import BaseClass

def test_template():
assert True
Expand All @@ -73,17 +73,17 @@ def test_base_class():
All your test suites can be run by calling from command line (a full list of arguments can be found [here](https://docs.pytest.org/en/8.0.x/)):

```bash
pytest -v --cov-fail-under=90 --cov=template_workshop -l --tb=short --maxfail=1 tests/
pytest -v --cov-fail-under=90 --cov=ukp_template_workshop -l --tb=short --maxfail=1 tests/
```

Let's now turn to the class you've just implemented. You want to make sure your code *actually* works and handles all cases. For example, have you thought of what would happen if someone called `template_workshop -1`? First, write code in Fibonacci to handle what to do with negative (or zero) numbers. Then, write tests for `Fibonacci` to check that your code actually works. Your test should all complete successfully and coverage (as computed by the command above) should be at least 90% (as controlled by the `--cov-fail-under=90` in the command above.
Let's now turn to the class you've just implemented. You want to make sure your code *actually* works and handles all cases. For example, have you thought of what would happen if someone called `ukp_template_workshop -1`? First, write code in Fibonacci to handle what to do with negative (or zero) numbers. Then, write tests for `Fibonacci` to check that your code actually works. Your test should all complete successfully and coverage (as computed by the command above) should be at least 90% (as controlled by the `--cov-fail-under=90` in the command above.

### What to change

You need to work on the following files:

- `tests/tests_fib.py`: Contains the test suite for the Fibonacci class. Change it to obtain 90% coverage.
- `template_workshop/fibonacci.py`: Contains the Fibonacci class. Change it to fix bugs found during testing.
- `ukp_template_workshop/fibonacci.py`: Contains the Fibonacci class. Change it to fix bugs found during testing.

## 🩺 Task 3 - Using GitHub Actions to check for mistakes

Expand Down Expand Up @@ -120,9 +120,9 @@ jobs: # List of separate jobs to run
--fail-under=9.0 \
$(git ls-files '*.py') || echo "::warning::Pylint check failed, but the workflow will continue."
```
GitHub Actions are called after a specific trigger is detected, in the case above a push action on the main branch of your repo. GitHub Actions are implemented in the `.github/workflows` folder, and results of previous runs are in your repository's [Actions tab](https://github.com/akatief/template-workshop/actions). You can inspect the action output to understand why a specific action fails.
GitHub Actions are called after a specific trigger is detected, in the case above a push action on the main branch of your repo. GitHub Actions are implemented in the `.github/workflows` folder, and results of previous runs are in your repository's [Actions tab](https://github.com/ibigoula/UKP_Template_Workshop/actions). You can inspect the action output to understand why a specific action fails.

Familiarize with the [Actions interface](https://github.com/akatief/template-workshop/actions) and understand why some of them fail. Then, apply changes to the repository to fix them. Finally, push the changes to GitHub to run the actions again. They should all show a ✅ on the page.
Familiarize with the [Actions interface](https://github.com/ibigoula/UKP_Template_Workshop/actions) and understand why some of them fail. Then, apply changes to the repository to fix them. Finally, push the changes to GitHub to run the actions again. They should all show a ✅ on the page.

### What to change

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ For full documentation visit [mkdocs.org](https://www.mkdocs.org).

## Docs

::: template_workshop
::: ukp_template_workshop
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
site_name: template_workshop
site_name: ukp_template_workshop
nav:
- Home: index.md

Expand All @@ -8,7 +8,7 @@ theme:
plugins:
- search
- mkdocstrings:
project_name: template_workshop
project_name: ukp_template_workshop
handlers:
python:
options:
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Python setup.py for template_workshop package"""
"""Python setup.py for ukp_template_workshop package"""
import io
import os
from setuptools import find_packages, setup


def read(*paths, **kwargs):
"""Read the contents of a text file safely.
>>> read("template_workshop", "VERSION")
>>> read("ukp_template_workshop", "VERSION")
'0.1.0'
>>> read("README.md")
...
Expand All @@ -30,15 +30,15 @@ def read_requirements(path):


setup(
name="template_workshop",
url="https://github.com/akatief/template-workshop/",
name="ukp_template_workshop",
url="https://github.com/ibigoula/UKP_Template_Workshop/",
long_description=read("README.md"),
long_description_content_type="text/markdown",
author="author_name",
packages=find_packages(exclude=["tests", ".github"]),
install_requires=read_requirements("requirements.txt"),
entry_points={
"console_scripts": ["template_workshop = template_workshop.__main__:main"]
"console_scripts": ["ukp_template_workshop = ukp_template_workshop.__main__:main"]
},
extras_require={"test": read_requirements("requirements-dev.txt")},
)
6 changes: 0 additions & 6 deletions template_workshop/__main__.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tests are defined here
import pytest
from template_workshop import BaseClass
from ukp_template_workshop import BaseClass

def test_template():
assert True
Expand Down
4 changes: 2 additions & 2 deletions tests/test_fib.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest
from template_workshop import Fibonacci
from ukp_template_workshop import Fibonacci

def test_import():
# This checks __init__ was set up correctly
try:
from template_workshop import Fibonacci
from ukp_template_workshop import Fibonacci
except ImportError:
assert False

Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions ukp_template_workshop/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Entry point for ukp_template_workshop."""

from ukp_template_workshop.cli import main # pragma: no cover

if __name__ == "__main__": # pragma: no cover
main()
File renamed without changes.
4 changes: 2 additions & 2 deletions template_workshop/cli.py → ukp_template_workshop/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""CLI interface for template_workshop project.
"""CLI interface for ukp_template_workshop project.
Be creative! do whatever you want!
Expand All @@ -14,7 +14,7 @@
def main(): # pragma: no cover
"""
The main function executes on commands:
`python -m template_workshop` and `$ template_workshop `.
`python -m ukp_template_workshop` and `$ ukp_template_workshop `.
This is your program's entry point.
Expand Down
File renamed without changes.

0 comments on commit cf58715

Please sign in to comment.