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
Once we find a file of interest from a registered directory, we can retrieve its metadata, or other files in the same directory, or the entire directory itself:
sr.retrieve_metadata(mydir + "/metadata.json", url)
sr.list_files(mydir, url)
sr.retrieve_file(mydir + "/diet/metadata.json", url)
sr.retrieve_directory(mydir, url)
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.
Metadata
Release files for SewerRat 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sewerrat-0.3.1.tar.gz | 31.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sewerrat-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.7 kB
Release files / sewerrat-0.3.1.tar.gz
| Download URL | sewerrat-0.3.1.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
996fbb9a73ac01fbce6fa56ba584973361ce35f452133a785fab478c0d345609
|
|
BLAKE2b-256 checksum How to use checksums |
16159d3eb266c05618297ccba534419844961aab088d754b01696861e3de9d13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / sewerrat-0.3.1-py3-none-any.whl
| Download URL | sewerrat-0.3.1-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4e82956de15cb829c20b7461a8095a7aab0d82b78ae7cb0f48e23562e93f869
|
|
BLAKE2b-256 checksum How to use checksums |
3f1dfc6db6974c650ba7e18de9b7e532d001eea0d54c7f66c36ea806da8ddcb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|