Install & Compatibility
Where this runs
tested against v1.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
✕ build_error
✕ build_error
py 3.11
✕ build_error
✕ build_error
py 3.12
✕ build_error
✕ build_error
py 3.13
✕ build_error
✕ build_error
23MB installed
● package 23MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Model
✓ import yorm
class MyModel(yorm.Model):
Base class for YORM models.
attr
✓ import yorm
@yorm.attr(autosave=True)
class MyModel(yorm.Model):
Decorator for classes and attributes. Use `@yorm.attr(autosave=True)` for class-level autosaving or `my_attr = yorm.attr(type=str)` for attribute definition.
sync
✓ import yorm
yorm.sync(MyModel, 'path/to/data.yaml')
✗ yorm.sync(MyModel)
As of v1.6, `yorm.sync()` requires a path argument. Implicit paths are deprecated.
This quickstart demonstrates how to define a YORM model, synchronize it with a temporary YAML file, create and update objects, and verify persistence. It uses `autosave=True` for automatic saving of changes.
import yorm
import os
import tempfile
import shutil
# Create a temporary directory for the YAML file
temp_dir = tempfile.mkdtemp()
try:
# Define a model with autosave enabled at the class level
@yorm.attr(autosave=True)
class Person(yorm.Model):
name = yorm.attr(type=str)
email = yorm.attr(type=str, default='')
# Synchronize the model with a YAML file in the temporary directory
file_path = os.path.join(temp_dir, 'person.yaml')
yorm.sync(Person, file_path)
print(f"Synchronized Person model with: {file_path}")
# Create a new person object. Due to autosave=True, it's saved automatically.
print("\nCreating Bob...")
bob = Person(name="Bob", email="bob@example.com")
print(f"Bob created: {bob.name} ({bob.email})")
# Update an attribute. The change is saved automatically.
print("Updating Bob's email...")
bob.email = "robert@example.com"
print(f"Bob's email updated to: {bob.email}")
# Fetch all persons (should be just Bob)
print("\nFetching all persons...")
persons = Person.all()
for p in persons:
print(f"Found: {p.name} ({p.email})")
# Verify the update by reloading and checking
if persons and persons[0].email == "robert@example.com":
print("Update verified: Bob's email is now robert@example.com")
else:
print("Error: Bob's email not updated as expected.")
# Delete all persons. This also gets persisted.
print("\nDeleting all persons...")
Person.all().clear()
print(f"Persons remaining after clear: {len(Person.all())}")
finally:
# Clean up the temporary directory
shutil.rmtree(temp_dir)
print(f"\nCleaned up temporary directory: {temp_dir}")
Upgrade
Version history
1.6.2latest on PyPI · released Mar 23, 2019
Audit
Dependencies
No dependency data recorded yet.