Skip to content

Commit

Permalink
File organization (#885)
Browse files Browse the repository at this point in the history
* Move files to subfolders

* Make lib/ into a package

* Update lib file locations

* Update github actions

* Fix links

* Ignore all __pycache__ directories
  • Loading branch information
MarkZH authored Jan 18, 2024
1 parent 64146f9 commit 6eaacb4
Show file tree
Hide file tree
Showing 23 changed files with 529 additions and 533 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r test-requirements.txt
pip install -r test_bot/test-requirements.txt
- name: Run mypy
run: |
mypy --strict .
2 changes: 1 addition & 1 deletion .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r test-requirements.txt
pip install -r test_bot/test-requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r test-requirements.txt
pip install -r test_bot/test-requirements.txt
- name: Restore engines
id: cache-temp-restore
uses: actions/cache/restore@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import datetime
import os

with open("versioning.yml") as version_file:
with open("lib/versioning.yml") as version_file:
versioning_info = yaml.safe_load(version_file)

current_version = versioning_info["lichess_bot_version"]
Expand All @@ -19,7 +19,7 @@

versioning_info["lichess_bot_version"] = new_version

with open("versioning.yml", "w") as version_file:
with open("lib/versioning.yml", "w") as version_file:
yaml.dump(versioning_info, version_file, sort_keys=False)

with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
config.yml
__pycache__
test_bot/__pycache__
**/__pycache__
/engines/*
!/engines/README.md
128 changes: 64 additions & 64 deletions CODE_OF_CONDUCT.md → docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
# Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html

For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq
# Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html

For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq
114 changes: 57 additions & 57 deletions CONTRIBUTING.md → docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
# Contributing to lichess-bot

We welcome your contributions! There are multiple ways to contribute.

## Table of Contents

1. [Code of Conduct](#code-of-conduct)
2. [How to Contribute](#how-to-contribute)
3. [Reporting Bugs](#reporting-bugs)
4. [Requesting Features](#requesting-features)
5. [Submitting Pull Requests](#submitting-pull-requests)
6. [Testing](#testing)
7. [Documentation](#documentation)

## Code of Conduct

Please review our [Code of Conduct](/CODE_OF_CONDUCT.md) before participating in our community. We want all contributors to feel welcome and to foster an open and inclusive environment.

## How to Contribute

We welcome contributions in the form of bug reports, feature requests, code changes, and documentation improvements. Here's how you can contribute:

- Fork the repository to your GitHub account.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with a clear and concise commit message.
- Push your changes to your branch.
- Submit a pull request to the main repository.

Please follow our [Pull Request Template](.github/pull_request_template.md) when submitting a pull request.

## Reporting Bugs

If you find a bug, please open an issue with a detailed description of the problem. Include information about your environment and steps to reproduce the issue.
When filing a bug remember that the better written the bug is, the more likely it is to be fixed.
Please follow our [Bug Report Template](.github/ISSUE_TEMPLATE/bug_report.md) when submitting a pull request.

## Requesting Features

We encourage you to open an issue to propose new features or improvements. Please provide as much detail as possible about your suggestion.
Please follow our [Feature Request Template](.github/ISSUE_TEMPLATE/feature_request.md) when submitting a pull request.

## Submitting Pull Requests

When submitting a pull request, please ensure the following:

- You have added or updated relevant documentation.
- Tests (if applicable) have been added or updated.
- Your branch is up-to-date with the main repository.
- The pull request title and description are clear and concise.

## Testing

Ensure that your changes pass all existing tests and consider adding new tests if applicable.

## Documentation

Improvements to the documentation are always welcome. If you find areas that need clarification or additional information, please submit a pull request.
# Contributing to lichess-bot

We welcome your contributions! There are multiple ways to contribute.

## Table of Contents

1. [Code of Conduct](#code-of-conduct)
2. [How to Contribute](#how-to-contribute)
3. [Reporting Bugs](#reporting-bugs)
4. [Requesting Features](#requesting-features)
5. [Submitting Pull Requests](#submitting-pull-requests)
6. [Testing](#testing)
7. [Documentation](#documentation)

## Code of Conduct

Please review our [Code of Conduct](/docs/CODE_OF_CONDUCT.md) before participating in our community. We want all contributors to feel welcome and to foster an open and inclusive environment.

## How to Contribute

We welcome contributions in the form of bug reports, feature requests, code changes, and documentation improvements. Here's how you can contribute:

- Fork the repository to your GitHub account.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with a clear and concise commit message.
- Push your changes to your branch.
- Submit a pull request to the main repository.

Please follow our [Pull Request Template](/.github/pull_request_template.md) when submitting a pull request.

## Reporting Bugs

If you find a bug, please open an issue with a detailed description of the problem. Include information about your environment and steps to reproduce the issue.
When filing a bug remember that the better written the bug is, the more likely it is to be fixed.
Please follow our [Bug Report Template](/.github/ISSUE_TEMPLATE/bug_report.md) when submitting a pull request.

## Requesting Features

We encourage you to open an issue to propose new features or improvements. Please provide as much detail as possible about your suggestion.
Please follow our [Feature Request Template](/.github/ISSUE_TEMPLATE/feature_request.md) when submitting a pull request.

## Submitting Pull Requests

When submitting a pull request, please ensure the following:

- You have added or updated relevant documentation.
- Tests (if applicable) have been added or updated.
- Your branch is up-to-date with the main repository.
- The pull request title and description are clear and concise.

## Testing

Ensure that your changes pass all existing tests and consider adding new tests if applicable.

## Documentation

Improvements to the documentation are always welcome. If you find areas that need clarification or additional information, please submit a pull request.
File renamed without changes.
1 change: 1 addition & 0 deletions lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""This lib folder contains the library code necessary for running lichess-bot."""
File renamed without changes.
8 changes: 4 additions & 4 deletions conversation.py → lib/conversation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Allows lichess-bot to send messages to the chat."""
from __future__ import annotations
import logging
import model
from engine_wrapper import EngineWrapper
from lichess import Lichess
from lib import model
from lib.engine_wrapper import EngineWrapper
from lib.lichess import Lichess
from collections.abc import Sequence
from timer import seconds
from lib.timer import seconds
MULTIPROCESSING_LIST_TYPE = Sequence[model.Challenge]

logger = logging.getLogger(__name__)
Expand Down
10 changes: 4 additions & 6 deletions engine_wrapper.py → lib/engine_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
from collections import Counter
from collections.abc import Generator, Callable
from contextlib import contextmanager
import config
import model
import lichess
from config import Configuration
from timer import Timer, msec, seconds, msec_str, sec_str, to_seconds
from lib import config, model, lichess
from lib.config import Configuration
from lib.timer import Timer, msec, seconds, msec_str, sec_str, to_seconds
from typing import Any, Optional, Union, Literal
OPTIONS_TYPE = dict[str, Any]
MOVE_INFO_TYPE = dict[str, Any]
Expand Down Expand Up @@ -587,7 +585,7 @@ def getHomemadeEngine(name: str) -> type[MinimalEngine]:
:param name: The name of the homemade engine.
:return: The engine with this name.
"""
import strategies
from lib import strategies
engine: type[MinimalEngine] = getattr(strategies, name)
return engine

Expand Down
2 changes: 1 addition & 1 deletion lichess.py → lib/lichess.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import traceback
from collections import defaultdict
import datetime
from timer import Timer, seconds, sec_str
from lib.timer import Timer, seconds, sec_str
from typing import Optional, Union, Any
import chess.engine
JSON_REPLY_TYPE = dict[str, Any]
Expand Down
Loading

0 comments on commit 6eaacb4

Please sign in to comment.