-
Notifications
You must be signed in to change notification settings - Fork 0
AP-564_extracting-tind-client #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jason-raitz
wants to merge
2
commits into
main
Choose a base branch
from
AP-564_extracting-tind-client
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [flake8] | ||
| max-line-length = 100 | ||
| # Equivalent to allow-init-docstring, which we set on pydoclint. | ||
| extend-ignore = DOC301,F401 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,33 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
|
|
||
| on: [push, pull_request] | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.13"] | ||
| python-version: | ||
| - "3.13" | ||
| - "3.14" | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| version: "0.10.7" | ||
| python-version: ${{ matrix.python-version }} | ||
| enable-cache: true | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install ".[test,lint]" | ||
| - name: Sync dependencies | ||
| run: uv sync --locked --all-extras --dev | ||
|
|
||
| - name: Lint with pylint | ||
| run: pylint tind_client/ | ||
| run: uv run pylint tind_client tests | ||
|
|
||
| - name: Type-check with mypy | ||
| run: mypy tind_client/ | ||
| run: uv run mypy tind_client tests | ||
|
|
||
| - name: Run tests | ||
| run: pytest | ||
| run: uv run pytest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # python-tind-client | ||
|
|
||
| Python library for interacting with the [TIND ILS](https://tind.io) API. | ||
| Python library for interacting with the [TIND DA](https://tind.io) API. | ||
|
|
||
| ## Requirements | ||
|
|
||
|
|
@@ -23,11 +23,11 @@ pip install "python-tind-client[debug]" # debugpy | |
|
|
||
| ## Configuration | ||
|
|
||
| Create a `TINDClient` with explicit configuration values: | ||
| Create a `TINDClient` with optional configuration values: | ||
|
|
||
| - `api_key` (required): Your TIND API token | ||
| - `api_url` (required): Base URL of the TIND instance (e.g. `https://tind.example.edu`) | ||
| - `default_storage_dir` (optional): Default output directory for downloaded files | ||
| - `api_key` (optional): Your TIND API token. Falls back to the `TIND_API_KEY` environment variable. | ||
| - `api_url` (optional): Base URL of the TIND instance (e.g. `https://tind.example.edu`). Falls back to the `TIND_API_URL` environment variable. | ||
|
Comment on lines
+28
to
+29
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good, but just to be really clear, it might be nice to have an environment variables subsection like we do in the Willa readme for easy reference. |
||
| - `default_storage_dir` (optional): Default output directory for downloaded files. Defaults to `./tmp`. | ||
|
|
||
| ## Usage | ||
|
|
||
|
|
@@ -44,39 +44,35 @@ client = TINDClient( | |
|
|
||
| ### Fetch pyMARC metadata for a record | ||
| ```python | ||
| record = client.fetch_metadata("12345") | ||
| record = client.fetch_metadata("116262") | ||
| print(record["245"]["a"]) # title | ||
| ``` | ||
|
|
||
| ### Fetch file metadata for a record | ||
| ```python | ||
| metadata = client.fetch_file_metadata("12345") | ||
| print(metadata[0]) # first file metadata dict | ||
| print(metadata[0]["url"]) # file download URL | ||
| metadata = client.fetch_file_metadata("116262") | ||
| print(metadata[0]) # first file metadata dict | ||
| print(metadata[0]["url"]) # file download URL | ||
| ``` | ||
|
|
||
| ### Download a file | ||
| ```python | ||
| # use metadata from previous example | ||
| path_to_download = client.fetch_file(metadata[0].url) | ||
| path_to_download = client.fetch_file(metadata[0]["url"]) | ||
| ``` | ||
|
|
||
| ## Functional fetch API | ||
|
|
||
| The functions in `tind_client.fetch` are available for direct use and now accept | ||
| explicit credentials instead of a client object. | ||
|
|
||
| ### Search for records | ||
| ```python | ||
| from tind_client.fetch import fetch_metadata | ||
| # return a list of record IDs matching a query | ||
| ids = client.fetch_ids_search("collection:'Disabled Students Program Photos'") | ||
|
|
||
| record = fetch_metadata( | ||
| "12345", | ||
| api_key="your-token", | ||
| api_url="https://tind.example.edu", | ||
| ) | ||
| ``` | ||
| # return PyMARC records matching a query | ||
| records = client.fetch_search_metadata("collection:'Disabled Students Program Photos'") | ||
|
|
||
| For most use cases, prefer `TINDClient` methods as the primary interface. | ||
| # return raw XML or PyMARC records from a paginated search | ||
| xml_results = client.search("collection:'Disabled Students Program Photos'", result_format="xml") | ||
| pymarc_results = client.search("collection:'Disabled Students Program Photos'", result_format="pymarc") | ||
| ``` | ||
|
|
||
| ## Running tests | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,15 @@ | ||
| """ | ||
| python-tind-client — Python library for interacting with the TIND ILS API. | ||
| python-tind-client — Python library for interacting with the TIND DA API. | ||
| """ | ||
|
|
||
| __copyright__ = "© 2026 The Regents of the University of California. MIT license." | ||
|
|
||
| from .client import TINDClient | ||
| from .api import tind_download, tind_get | ||
| from .errors import AuthorizationError, RecordNotFoundError, TINDError | ||
| from .fetch import ( | ||
| fetch_file, | ||
| fetch_file_metadata, | ||
| fetch_ids_search, | ||
| fetch_marc_by_ids, | ||
| fetch_metadata, | ||
| fetch_search_metadata, | ||
| search, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "TINDClient", | ||
| "tind_get", | ||
| "tind_download", | ||
| "AuthorizationError", | ||
| "RecordNotFoundError", | ||
| "TINDError", | ||
| "fetch_metadata", | ||
| "fetch_file", | ||
| "fetch_file_metadata", | ||
| "fetch_ids_search", | ||
| "fetch_marc_by_ids", | ||
| "fetch_search_metadata", | ||
| "search", | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this truly a change if there hasn't been a release yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point. I'll move any changes up to the added category before marking ready for review.