Python client for the SewerRat API
Project description
Python interface to the SewerRat API
Pretty much as it says on the tin: provides a Python client for the API of the same name. It is assumed that the users of the sewerrat client and the SewerRat API itself are accessing the same shared filesystem; this is typically the case for high-performance computing clusters in scientific institutions. To demonstrate, let's spin up a mock SewerRat instance:
import sewerrat as sr
_, url = sr.start_sewerrat()
Let's mock up a directory of metadata files:
import tempfile
import os
mydir = tempfile.mkdtemp()
with open(os.path.join(mydir, "metadata.json"), "w") as handle:
handle.write('{ "first": "foo", "last": "bar" }')
os.mkdir(os.path.join(mydir, "diet"))
with open(os.path.join(mydir, "diet", "metadata.json"), "w") as handle:
handle.write('{ "fish": "barramundi" }')
We can then easily register it via the register()
function.
Similarly, we can deregister this directory with deregister(mydir)
.
# Only indexing metadata files named 'metadata.json'.
sr.register(mydir, names=["metadata.json"], url=url)
To search the index, we use the query()
function to perform free-text searches.
This does not require filesystem access and can be done remotely.
sr.query(url, "foo")
sr.query(url, "bar%") # partial match to 'bar...'
sr.query(url, "bar% AND foo") # boolean operations
sr.query(url, "fish:bar%") # match in the 'fish' field
We can also search on the user, path components, and time of creation:
sr.query(url, user="LTLA") # created by myself
sr.query(url, path="diet/") # path has 'diet/' in it
import time
sr.query(url, after=time.time() - 3600) # created less than 1 hour ago
Check out the API documentation for more details on each function. For the concepts underlying the SewerRat itself, check out the repository for a detailed explanation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sewerrat-0.1.0.tar.gz
.
File metadata
- Download URL: sewerrat-0.1.0.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df193e76b50225ad1b40ffa89bca1e7f6bfdf6e7184f4bcfc6fcc024708f317d |
|
MD5 | 02a95ac7efc5f7a9f464c1c74122736a |
|
BLAKE2b-256 | 7c9c1ea0190962d02a3cc45c8c72ad692bad96074f4f2e61578a5bb229741cfa |
File details
Details for the file SewerRat-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: SewerRat-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52cfe8136e8a27e2422cdacb7fb5fde1e689719c93c913f5c00f4e174c5618a2 |
|
MD5 | c36af6f852225dd806cd7151bdc17b20 |
|
BLAKE2b-256 | 2c0afdfe64aadf45004f19b27c83bba1070be56b0fbbacb1b394297a4130356e |