Skip to content
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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Pull requests should be focused and address a single concern. Include a clear de
- All new code MUST include appropriate tests. This project proudly maintains over 90% test coverage.
- Python tests for wp1/logic/foo.py should live in wp1/logic/foo_test.py.
- Use the provided base test classes (in `base_db_test.py` and `wiki_db_test.py`). When you call `super().setUp()`, the base test class will handle giving you a fresh, empty database.
- Feel free ot make liberal use of `@patch` and mocks in Python tests.
- Feel free to make liberal use of `@patch` and mocks in Python tests.
- Cypress frontend tests should almost ALWAYS mock the backend API (see the `fixtures` directory).
- Similarly, Python tests should NEVER make actual outbound network requests, even if a service is free, idempotent or reliably available. Always mock the necessary methods on the `requests` library.
- Follow existing patterns and conventions in the codebase. In particular:
- The Python code is not generally object oriented, but instead uses dependency injection to provide necessary objects like the `wp10db` database connection.
- The main exception to this is that data models that have tables in the database should have an [attrs](https://www.attrs.org/en/stable/) based data model class. So there is a a `selections` table and a `selection.py` data model class.
- Flask API handlers (in `wp1/web/`) should strive to be as "lean" as possible. Don't put lots of complex logic there, instead delegate to methods in `wp1/logic`.
- Long running or periodic tasks should be delegated to `rq`.
- It is better to raise an exception and "crash" a request than to give an incorrect or incomplete answer. However, forseeable error conditions should be handled, including providing detailed error messages.
- It is better to raise an exception and "crash" a request than to give an incorrect or incomplete answer. However, foreseeable error conditions should be handled, including providing detailed error messages.
- User data should be validated on the frontend as a convenience, when possible. However ultimately all validation and policy enforcement is done in the backend.

## Usage of LLMs/AI coding assistants
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ You may need to install the `jq` tool with [these instructions](https://github.c
necessary as they contain the latest parameters needed to run the `mwoffliner`
scraper.

In your `credentials.py`, set the defintion version to any of the versions pulled from the API. For example, if `1.17.2` was one of the downloaded definitions of the mwoffliner scraper, you want to set `definition_version` under the `ZIMFARM` section:
In your `credentials.py`, set the definition version to any of the versions pulled from the API. For example, if `1.17.2` was one of the downloaded definitions of the mwoffliner scraper, you want to set `definition_version` under the `ZIMFARM` section:

```py
"ZIMFARM": {
Expand Down Expand Up @@ -277,7 +277,7 @@ pipenv run flask --app wp1.web.app --debug run
```

If you're having difficulties connecting to the backend server from the
frontend, especially in cypress e2e tests, and espcially on macOS, it might have
frontend, especially in cypress e2e tests, and especially on macOS, it might have
something to do with IPv4 versus IPv6 networking stacks. You can try adding the
option `--host 127.0.0.1` to the command line above (see
https://github.com/openzim/wp1/pull/859).
Expand Down
2 changes: 1 addition & 1 deletion docker/dev-db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ More information on YoYo Migrations is available

After migrations have been applied to production and are stable, it makes sense
to "permanently" apply them to the dev database dump so that the migrations do
not have to be run everytime the dev database is recreated.
not have to be run every time the dev database is recreated.

As part of this process, you will create a MySQL dump file of the dev database.
It is important to recognize that all data from your dev database will be included
Expand Down
2 changes: 1 addition & 1 deletion wp1/credentials.py.dev.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# for the dev rq workers, which run within the docker-compose environment and must
# connect to redis and mysql using special paths.

# To get end-to-end testing in the dev enviroment to work YOU MUST EDIT THIS FILE in
# To get end-to-end testing in the dev environment to work YOU MUST EDIT THIS FILE in
# the places indicated, then copy it to wp1/wp1/credentials.py.dev. Specifically, edit
# the objects for the key 'STORAGE'.

Expand Down
2 changes: 1 addition & 1 deletion wp1/logic/builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,7 @@ def test_regenerate_zim_updates_old_task_when_selection_version_changed(
self, mock_utcnow, mock_request_zimfarm_task
):
"""
Ensure the existing zim_task is updated (not dupplicated) when the selection version changes.
Ensure the existing zim_task is updated (not duplicated) when the selection version changes.
"""
self._insert_builder()
zim_schedule_id = self._setup_failed_zim_regeneration_scenario(
Expand Down
4 changes: 2 additions & 2 deletions wp1/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ def update_pageviews(filter_lang=None, commit_after=50000):

n += 1
if n >= commit_after:
logger.debug("Commiting in temp db")
logger.debug("Committing in temp db")
wp10db.commit()
n = 0
wp10db.commit()
logger.debug("Swaping data from temp db to scores db")
logger.debug("Swapping data from temp db to scores db")
swap_temp_pageviews_to_scores(wp10db)
reset_missing_articles_pageviews(wp10db)
truncate_temp_pageviews(wp10db)
Expand Down
2 changes: 1 addition & 1 deletion wp1/web/oauth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def test_initiate_dev_mode_idempotency(self):
@patch("wp1.web.oauth.ENV", Environment.DEVELOPMENT)
@patch("wp1.web.oauth.CREDENTIALS", DEV_NO_CREDS)
def test_initiate_dev_mode_multiple_sessions_same_user(self):
"""Test : different sesssions hitting initiate don't duplicate users."""
"""Test : different sessions hitting initiate don't duplicate users."""
self.app = create_app()
with self.override_db(self.app):
with self.app.test_client() as client1:
Expand Down
Loading