Skip to content

Commit 1e20d64

Browse files
committed
fix, feat: 'git_repo' is present in /categories, remove unnecessary makefile commands, update to python 3.12.10 for docker image, closes 20
1 parent 8718837 commit 1e20d64

File tree

7 files changed

+25
-37
lines changed

7 files changed

+25
-37
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim-bookworm
1+
FROM python:3.12.10-slim-bookworm
22

33
USER root
44

@@ -19,4 +19,4 @@ RUN pip install .
1919
EXPOSE 8000
2020
ENV LISTEN_PORT=8000
2121

22-
CMD ["uvicorn", "api.main:app", "--host=0.0.0.0", "--proxy-headers"]
22+
CMD ["fastapi", "run", "api/main.py"]

Makefile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
.PHONY: build
22

33
build:
4-
pip install . -U
5-
6-
run:
7-
fastapi dev api/main.py
4+
echo "Nothing to build here."
85

96
test:
107
ruff check .
118

12-
install:
13-
pip install . -U
14-
15-
install-dev:
16-
pip install .[dev] -U
17-
189
pull-repo:
1910
git clone https://github.com/cat-milk/Anime-Girls-Holding-Programming-Books ./assets/git_repo
2011

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Now you may jump to **step 2** of the [docker method](#-docker-method-recommende
8080

8181
#### Prerequisites:
8282
- [Git](https://git-scm.com/downloads)
83-
- [Python](https://www.python.org/downloads/) (3.8 - 3.11)
83+
- [Python](https://www.python.org/downloads/) (3.10 - 3.13)
8484
- [Make](https://www.gnu.org/software/make/#download) ***(otherwise you'll have to copy the commands from the [Makefile](https://github.com/THEGOLDENPRO/aghpb_api/blob/main/Makefile))***
8585

8686
1. Clone the repo.
@@ -94,14 +94,14 @@ source env/bin/activate # For windows it's --> cd env/Scripts && activate && cd
9494
```
9595
3. Install the API's dependencies.
9696
```sh
97-
make
97+
pip install . -U
9898
```
9999
4. Pull the ~~anime girls~~ programming books.
100100
```sh
101101
make pull-repo
102102
```
103-
5. Run that sh#t.
103+
5. Run that mf.
104104
```sh
105-
make run
105+
fastapi dev api/main.py
106106
```
107107
6. Visit ``localhost:8000`` in your browser, then all should be good! 🌈

api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.4.6"
1+
__version__ = "1.4.7"

api/main.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@
1313
from slowapi.util import get_remote_address
1414
from slowapi.errors import RateLimitExceeded
1515

16-
from meow_inator_5000.woutews import nya_service
17-
1816
from . import __version__
1917
from .info import InfoData
2018
from .book import Book, BookData
2119
from .repository import ProgrammingBooks
2220
from .constants import RANDOM_BOOK_RATE_LIMIT, GET_BOOK_RATE_LIMIT, GIT_REPO_PATH
2321
from .errors import (
24-
APIException,
25-
CategoryNotFoundError,
26-
BookNotFoundError,
27-
RateLimitedError,
22+
APIException,
23+
CategoryNotFoundError,
24+
BookNotFoundError,
25+
RateLimitedError,
2826
rate_limit_error_handler
2927
)
3028

@@ -92,7 +90,6 @@
9290
root_path = ROOT_PATH
9391
)
9492
app.state.limiter = limiter
95-
app.include_router(nya_service.router)
9693
app.add_exception_handler(RateLimitExceeded, rate_limit_error_handler)
9794

9895
@app.get(
@@ -172,8 +169,8 @@ async def categories() -> List[str]:
172169
tags = ["books"]
173170
)
174171
async def search(
175-
query: str,
176-
category: str = None,
172+
query: str,
173+
category: str = None,
177174
limit: int = Query(ge = 1, default = 50)
178175
) -> List[BookData]:
179176
"""Returns list of book objects."""

api/repository.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ def parse_books(self) -> None:
124124
add_msg = f"{Colours.GREY.apply(f'({index}/{file_count})')} Adding book from '{Colours.PINK_GREY.apply(shorter_path(file))}'...\n"
125125
sys.stdout.write(Colours.BLUE.apply("[CACHED] ") + add_msg if cached_book is not None else add_msg)
126126

127-
if cached_book is not None:
127+
if cached_book is None:
128+
book = Book(file, str(search_id))
129+
cached_books[str(file)] = book.to_dict()
130+
else:
128131
book = Book(
129132
file,
130133
str(search_id),
@@ -136,10 +139,6 @@ def parse_books(self) -> None:
136139
commit_hash = cached_book["commit_hash"]
137140
)
138141

139-
else:
140-
book = Book(file, str(search_id))
141-
cached_books[str(file)] = book.to_dict()
142-
143142
if file.parent.name not in categories:
144143
categories.append(file.parent.name)
145144

@@ -148,6 +147,9 @@ def parse_books(self) -> None:
148147

149148
self.__set_cache(cached_books)
150149

150+
if "git_repo" in categories:
151+
categories.remove("git_repo")
152+
151153
self.books = books
152154
self.categories = categories
153155

pyproject.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = [
55
{name = "Goldy", email = "[email protected]"}
66
]
77
readme = {file = "README.md", content-type = "text/markdown"}
8-
requires-python = ">=3.8"
8+
requires-python = ">=3.9"
99
license = { file = "LICENSE" }
1010
keywords = [
1111
"aghpb_api", "aghpb", "anime girls holding programming books"
@@ -15,19 +15,17 @@ classifiers = [
1515
'Operating System :: Microsoft :: Windows :: Windows 10',
1616
'Operating System :: POSIX :: Linux',
1717
'License :: OSI Approved :: MIT License',
18-
'Programming Language :: Python :: 3.9',
19-
'Programming Language :: Python :: 3.10',
2018
'Programming Language :: Python :: 3.11',
21-
'Programming Language :: Python :: 3.12'
19+
'Programming Language :: Python :: 3.12',
20+
'Programming Language :: Python :: 3.13',
2221
]
2322
dependencies = [
2423
"thefuzz",
2524
"fastapi[standard]",
26-
"devgoldyutils>=2.5.8",
25+
"devgoldyutils==3.0.0",
2726
"typing-extensions",
2827
"slowapi",
2928
"python-decouple",
30-
"meow-inator-5000@git+https://github.com/THEGOLDENPRO/meow-inator-5000",
3129
]
3230

3331
dynamic = ["version"]

0 commit comments

Comments
 (0)