Skip to content

A library to convert `slow_learner` output to different types

License

Notifications You must be signed in to change notification settings

gorkaerana/slow-learner-convert

Repository files navigation

slow-learner-convert

A library to convert slow-learner output to different data model frameworks.

Usage

Following the example provided in the slow-learner announcing post and assuming Release.py is in the current directory, one would generate msgspec structs equivalent to the typing.TypedDict objects in Release.py by executing:

slow-learner-convert --input-file Release.py --output-file Release_msgspec.py --framework msgspec

More specifically, if example.py contains

from typing import TypedDict


class Foo(TypedDict):
    bar: str
	

Baz = TypedDict("Baz", {"qux": int})

then the command line program

slow-learner-convert --input-file example.py --framework attrs

will generate example_attrs.py, containing the following code.

import attrs
from typing import TypedDict


@attrs.define
class Foo:
    bar: str


@attrs.define
class Baz:
    qux: int

Currently four frameworks are supported:

Installation

python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -U pip
python3 -m pip install slow-learner-convert

Development

I used rye (with uv backend) while developing this:

git clone [email protected]:gorkaerana/slow-learner-convert.git
cd slow-learner-convert
rye sync

About

A library to convert `slow_learner` output to different types

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages