Skip to main content

Metatree is a DBMS that uses the filesystem itself as a tree-structured database.

Project description

metatreedb

Metatree is a DBMS that uses the filesystem itself to organize and manage data in a tree-structured format.

In metadata.json in each tree node, you can manage information about child nodes, which can also be used for searching.

Features

  • metadata-based index
  • db-level concurrency control

Installation

pip install metatreedb

Quick Start

Here's an example of using Metatree as a model repository by setting up a database with (model_name, version,) as identifiers:

from metatree import Metatree

metatree = Metatree(
    "/tmp/my-model-repository",
    (
        "model",
        "version",
    ),
)

import uuid
import pickle

from pathlib import Path

for i in range(1, 4):
    awful_uuid = uuid.uuid4()
    trained = Path("/tmp/metatree-files/trained.pkl")
    with open(trained, "wb") as f:
        pickle.dump(awful_uuid, f)
    metatree.put(f"my-awful-model/v{i}", trained)

This will create files and directories in your filesystem as shown:

 tree /tmp/my-model-repository
/tmp/my-model-repository
├── metadata.json
└── my-awful-model
    ├── metadata.json
    ├── v1
       ├── metadata.json
       └── trained.pkl
    ├── v2
       ├── metadata.json
       └── trained.pkl
    └── v3
        ├── metadata.json
        └── trained.pkl

To add metadata information, use find and update:

metatree.find("my-awful-model")
metatree.update(active="v2")
for i in range(1, 4):
    metatree.find(f"my-awful-model/v{i}").update(model_file="trained.pkl")

This will update the metadata.json files as follows:

 cat /tmp/my-model-repository/my-awful-model/metadata.json
{"children": ["v1", "v2", "v3"], "active": "v2"} cat /tmp/my-model-repository/my-awful-model/v*/metadata.json
{"model_file": "trained.pkl"}
{"model_file": "trained.pkl"}
{"model_file": "trained.pkl"}

You can use this search index to find files. By enclosing the keys from metadata.json within angle brackets <> and substituting them in location, you can perform searches as follows:

metatree.find("my-awful-model/<active>")
print(metatree.location)
# This returns `file:///tmp/my-model-repository/my-awful-model/v2

file = metatree.get("my-awful-model/<active>/<model_file>")
print(file)
# The given path translates to `my-awful-model/v2/trained.pkl`,
# and it returns generator object

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

metatreedb-0.1.6.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

metatreedb-0.1.6-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file metatreedb-0.1.6.tar.gz.

File metadata

  • Download URL: metatreedb-0.1.6.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for metatreedb-0.1.6.tar.gz
Algorithm Hash digest
SHA256 4c54182b4952ac93d8bedba38fbbe0a46f93a1124b637bbd9e4c89515f349d20
MD5 879379201ab87f9c9699337f1ac4a929
BLAKE2b-256 221a4a7c3db8927f25c2a97d98a75e3c8911071fe5a3ea952b5b5626d6d809e6

See more details on using hashes here.

File details

Details for the file metatreedb-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: metatreedb-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.19

File hashes

Hashes for metatreedb-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2ea5eeaa766c3226cea81e47536ba03c75f027ac168433e831e22a92bd201495
MD5 0fb07a5d12dd6af08ab602db039ddc6f
BLAKE2b-256 c312d7e8eb1aa700115e098d35e17dc298454a6e683ebb9109a201c711c333d1

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