Registry / ai-ml / pyglove

pyglove

JSON →
library0.4.5pypypi✓ verified 89d ago

PyGlove is a general-purpose Python library for manipulating Python objects, introducing symbolic object-oriented programming (SOOP). It facilitates meta-program writing and is used in complex machine learning scenarios like AutoML, evolutionary computing, and daily programming tasks by providing a mutable symbolic object model and a rich set of object manipulation operations. It is currently at version 0.4.5 and actively maintained with regular updates.

pip install pyglove
INSTALL
IMPORT
SIG · PYGLOVE
P
pyglove
ai-mlpythonv0.4.5
Install
2.3s avg
Import
954ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.4.5 · 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
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.997s · 24.1MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 2.3s · import 0.910s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pyglove
✓ import pyglove as pg

Define a symbolic class using `@pg.symbolize` and instantiate it. The object can then be used like a regular Python object.

import pyglove as pg @pg.symbolize class Hello: def __init__(self, subject): self._greeting = f'Hello, {subject}!' def greet(self): print(self._greeting) hello = Hello('World') hello.greet()
Debug
Known issues
breakingWhen overriding `pg.Object.__init__`, it is now mandatory to apply the `@pg.explicit_method_override` decorator. Failing to do so will result in an error, as it prevents accidental overrides of core PyGlove-managed methods.
fix
Add the `@pg.explicit_method_override` decorator to any overridden `__init__` method in `pg.Object` subclasses.
affects: >=0.4.2
deprecatedSeveral internal APIs were renamed. `pg.Object.schema` became `pg.Object.__schema__`, `pg.Object.type_name` became `pg.Object.__type_name__`, and `pg.Object.serialization_key` moved to `pg.JSONConvertible.__serialization_key__`. Similarly, `pg.Functor.signature` was renamed to `pg.Functor.__signature__`. Additionally, `pg.ContextualValue`, `pg.symbolic.GetAttributeContext`, and related methods were removed.
fix
Update usage to the new private API names (e.g., `__schema__`) or avoid direct use of removed internal components. Refer to release notes for precise renamings.
affects: >=0.3.0 (specific changes vary)
gotchaPyGlove operates on a mutable programming paradigm, which can introduce complexities and limitations, especially when refactoring existing code. Adapting models and trainers to conform to PyGlove's symbolic object constraints, particularly for generic subclassed models, can be more challenging than expected, as symbolic nodes constructed by initialization parameters might not behave as anticipated.
fix
Carefully review PyGlove's documentation on symbolic object-oriented programming (SOOP) and mutation. Be prepared for potential refactoring and validation efforts when integrating with complex or highly customized object hierarchies.
affects: All versions
deprecatedThe `pg.members` function and its alias `pg.schema` were replaced by symbolic member declaration using field annotations as the recommended approach for defining symbolic fields within classes.
fix
Migrate from `pg.members` or `pg.schema` to using Python type annotations (e.g., `field_name: pg.typing.Int()` or `field_name: int = pg.symbolic.Field(...)`) for declaring symbolic fields within `@pg.symbolize`d classes.
affects: >=0.3.0
Errors
Common errors & fixes
AttributeError: '...Object' object has no attribute '...'
This error occurs when attempting to access an attribute on a PyGlove symbolic object that does not exist or is not accessible within its symbolic context, often due to a typo, uninitialized attribute, or incorrect path in symbolic operations.
fix
Ensure the attribute name is correct and has been properly defined or initialized on the symbolic object. For attributes inferred from a symbolic parent chain (e.g., in a `pg.symbolize`d class), verify the attribute exists in an ancestor or the current context.
ModuleNotFoundError: No module named 'pyglove'
The PyGlove library is not installed in the current Python environment or the environment's Python path does not include the installation location.
fix
Install PyGlove using pip: `pip install pyglove`
TypeError: ...
This error often arises in PyGlove when a value assigned to a symbolic object's attribute does not conform to the predefined type specification (schema) for that attribute, which PyGlove's runtime typing system validates.
fix
Check the `pg.typing` schema defined for the symbolic object's attribute and ensure the value being assigned matches the expected type (e.g., `pg.typing.Int`, `pg.typing.Float`, `pg.typing.Str`, etc.).
KeyError: '...'
This occurs when trying to access an item in a PyGlove symbolic dictionary or a property of a symbolic object using a key that does not exist.
fix
Verify that the key you are trying to access exists in the symbolic dictionary or object. Use methods like `.get()` with a default value, or check for key existence using the `in` operator before access to prevent the error.
Upgrade
Version history
0.4.5latest on PyPI · released Jul 15, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources