Skip to content

Commit 052faf4

Browse files
authored
Merge pull request #3 from amaanjaved1/feature/update-relay-store
Feature/update relay store
2 parents a011dd2 + fc8cf2b commit 052faf4

6 files changed

Lines changed: 323 additions & 622 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pip install ratemyprofessors-client
1717

1818
## Available Functions
1919

20-
Create a client and call any of these methods. See the [full docs](docs/) for parameters, return types, and examples.
20+
Create a client and call any of these methods. See the [full docs](https://amaanjaved1.github.io/Rate-My-Professors-API-Client-Python/) for parameters, return types, and examples.
2121

2222
```python
2323
from rmp_client import RMPClient

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "ratemyprofessors-client"
7-
version = "0.1.0"
8-
description = "A Python API Client for RateMyProfessors."
7+
version = "2.0.0"
8+
description = "Typed, retrying, rate-limited unofficial Python client for the RateMyProfessors GraphQL API."
99
readme = "README.md"
1010
requires-python = ">=3.10"
1111
license = { text = "MIT" }
1212
authors = [
1313
{ name = "Amaan", email = "amaanjaved2004@gmail.com" },
1414
]
15-
keywords = ["ratemyprofessors", "api-client", "scraping", "ratings"]
15+
keywords = ["ratemyprofessors", "api-client", "graphql", "ratings"]
1616
classifiers = [
17-
"Development Status :: 4 - Beta",
17+
"Development Status :: 5 - Production/Stable",
1818
"Intended Audience :: Developers",
1919
"License :: OSI Approved :: MIT License",
2020
"Programming Language :: Python :: 3",
@@ -42,7 +42,8 @@ dev = [
4242
]
4343

4444
[project.urls]
45-
Repository = "https://github.com/amaanjaved1/Rate-My-Professors-API-Client-Python"
45+
Repository = "https://github.com/amaanjaved1/Rate-My-Professors-API-Client"
46+
Documentation = "https://amaanjaved1.github.io/Rate-My-Professors-API-Client/"
4647

4748
[tool.hatch.build.targets.wheel]
4849
packages = ["src/rmp_client"]

src/rmp_client/client.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from typing import Any, Dict, Iterator, List, Mapping, Optional, Tuple
1414

1515
from .config import RMPClientConfig
16-
from .errors import ParsingError
16+
from .errors import HttpError, ParsingError, RetryError, RMPAPIError
1717
from .http import HttpClient, HttpClientContext
1818
from .models import (
1919
CompareSchoolsResult,
@@ -197,7 +197,7 @@ def search_professors(
197197
"""Search professors by name (TeacherSearchResultsPageQuery)."""
198198
query_var: Dict[str, Any] = {"text": query}
199199
if school_id is not None:
200-
query_var["schoolID"] = school_id
200+
query_var["schoolID"] = _school_node_id(school_id)
201201

202202
data = self.raw_query({
203203
"operationName": "TeacherSearchResultsPageQuery",
@@ -250,7 +250,7 @@ def list_professors_for_school(
250250
) -> ProfessorSearchResult:
251251
"""List professors at a school. Wrapper around :meth:`search_professors`."""
252252
return self.search_professors(
253-
query=query or "",
253+
query=query if query else " ",
254254
school_id=str(school_id),
255255
page_size=page_size,
256256
cursor=cursor,
@@ -351,9 +351,12 @@ def get_professor_ratings_page(
351351
after = first.next_cursor if first.has_next_page else None
352352

353353
while after is not None:
354-
nxt = self._fetch_professor_ratings_page(
355-
professor_id, after=after, first=100, course_filter=course_filter
356-
)
354+
try:
355+
nxt = self._fetch_professor_ratings_page(
356+
professor_id, after=after, first=100, course_filter=course_filter
357+
)
358+
except (RMPAPIError, HttpError, RetryError):
359+
break
357360
all_ratings.extend(nxt.ratings)
358361
after = nxt.next_cursor if nxt.has_next_page else None
359362

@@ -459,7 +462,10 @@ def get_school_ratings_page(
459462
after = first.next_cursor if first.has_next_page else None
460463

461464
while after is not None:
462-
nxt = self._fetch_school_ratings_page(school_id, after=after, first=100)
465+
try:
466+
nxt = self._fetch_school_ratings_page(school_id, after=after, first=100)
467+
except (RMPAPIError, HttpError, RetryError):
468+
break
463469
all_ratings.extend(nxt.ratings)
464470
after = nxt.next_cursor if nxt.has_next_page else None
465471

src/rmp_client/queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
node(id: $id) {
6868
... on School {
6969
id
70+
legacyId
7071
name
7172
city
7273
state

0 commit comments

Comments
 (0)