Filter repository artifacts#

Note

New in 2.0.0

In this guide, we’ll walk through strategies to filter lazyscribe.repository.Repository instances based on a version.

In our other documentation on versioning, we discuss how to load different versions of individual artifacts. In 2.0, we have added a feature to filter an entire lazyscribe.repository.Repository, creating a single set of output artifacts.

Datetime filtering#

Many times, we are looking for the latest set of artifacts available as of a given date. If you provide lazyscribe.repository.Repository.filter() with a datetime value or string, that’s exactly what it will give you:

from lazyscribe import Repository

repo = Repository(...)
new_repo: Repository = repo.filter("2025-01-01T00:00:00")

new_repo is a read-only repository with a maximum of one artifact version per unique name. That version will be the latest version available as of January 1, 2025.

Explicit versioning#

Datetime filtering is nice, but what if you want an explicit list of artifact versions?

from lazyscribe import Repository

repo = Repository(...)
new_repo = repo.filter(
    version=[
        ("my-first-artifact", 1),
        ("my-second-artifact", 0),
        ("my-third-artifact", 2)
    ]
)