Skip to main content

Python client for the SewerRat API

Project description

Python interface to the SewerRat API

Unit tests Documentation PyPI-Server

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.

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

sewerrat-0.2.7.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sewerrat-0.2.7-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file sewerrat-0.2.7.tar.gz.

File metadata

  • Download URL: sewerrat-0.2.7.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sewerrat-0.2.7.tar.gz
Algorithm Hash digest
SHA256 6bd2e9ed857c3b0253bc479e555ab1c4b9234a38e86e68c112e89bda2cff616e
MD5 ab09845fd5af61a23fd3c44523c3dd4c
BLAKE2b-256 79c25e5ca319d3e4ff41841057d6751cd02e958422cc00c160bd01376598ff2e

See more details on using hashes here.

File details

Details for the file sewerrat-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: sewerrat-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sewerrat-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e5843d968da567b9f117d75c14f1ca47333bd63356a97fb8c49909f33271a16f
MD5 9251218201e0310e7efdcf931634da58
BLAKE2b-256 472bfb2b13be84386dc0836b1164b0b2672b236827e72d34ea8cd6fd998e1add

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page