pyglove


Namepyglove JSON
Version 0.4.4 PyPI version JSON
download
home_pagehttps://github.com/google/pyglove
SummaryPyGlove: A library for manipulating Python objects.
upload_time2024-01-04 19:14:52
maintainer
docs_urlNone
authorPyGlove Authors
requires_python
licenseApache License 2.0
keywords ai machine learning automl mutable symbolic framework meta-programming
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <div align="center">
<img src="https://raw.githubusercontent.com/google/pyglove/main/docs/_static/logo_light.svg#gh-light-mode-only" width="320px" alt="logo"></img>

</div>

# PyGlove: Manipulating Python Programs

[![PyPI version](https://badge.fury.io/py/pyglove.svg)](https://badge.fury.io/py/pyglove)
[![codecov](https://codecov.io/gh/google/pyglove/branch/main/graph/badge.svg)](https://codecov.io/gh/google/pyglove)
![pytest](https://github.com/google/pyglove/actions/workflows/ci.yaml/badge.svg)

[**Getting started**](#hello-pyglove)
| [**Installation**](#install)
| [**Examples**](#examples)
| [**Reference docs**](https://pyglove.readthedocs.io/)

## What is PyGlove

PyGlove is a general-purpose library for Python object manipulation.
It introduces symbolic object-oriented programming to Python, allowing
direct manipulation of objects that makes meta-programs much easier to write.
It has been used to handle complex machine learning scenarios, such as AutoML,
as well as facilitating daily programming tasks with extra flexibility.

PyGlove is lightweight and has very few dependencies beyond the Python interpreter.
It provides:

* A mutable symbolic object model for Python;
* A rich set of operations for Python object manipulation;
* A solution for automatic search of better Python programs, including:
  * An easy-to-use API for dropping search into an arbitrary pre-existing Python
    program;
  * A set of powerful search primitives for defining the search space;
  * A library of search algorithms ready to use, and a framework for developing
    new search algorithms;
  * An API to interface with any distributed infrastructure (e.g. [Open Source Vizier](https://oss-vizier.readthedocs.io/en/latest/advanced_topics/pyglove/vizier_as_backend.html)) for such search.

It's commonly used in:

* Automated machine learning (AutoML);
* Evolutionary computing;
* Machine learning for large teams (evolving and sharing ML code, reusing
  ML techniques, etc.);
* Daily programming tasks in Python (advanced binding capabilities, mutability,
  etc.).

PyGlove has been [published](https://proceedings.neurips.cc/paper/2020/file/012a91467f210472fab4e11359bbfef6-Paper.pdf)
at NeurIPS 2020. It is widely used within [Alphabet](https://abc.xyz/), including Google Research, Google Cloud, Youtube and Waymo.

PyGlove is developed by Daiyi Peng and colleagues in [Google Brain Team](https://research.google/teams/brain/).


## Hello PyGlove

```python
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()
```
> Hello, World!

```python
hello.rebind(subject='PyGlove')
hello.greet()
```
> Hello, PyGlove!

```python
hello.rebind(subject=pg.oneof(['World', 'PyGlove']))
for h in pg.iter(hello):
  h.greet()
```
> Hello, World!<br>
> Hello, PyGlove!

## Install

```
pip install pyglove
```

Or install nightly build with:

```
pip install pyglove --pre
```

## Examples

* AutoML
  * [Neural Architecture Search on MNIST](https://github.com/google/pyglove/tree/main/examples/automl/mnist)
  * [NAS-Bench-101](https://github.com/google/pyglove/tree/main/examples/automl/nasbench)
  * [NATS-Bench](https://github.com/google/pyglove/tree/main/examples/automl/natsbench)
  * [Evolving Reinforcement Learning Algorithms](https://github.com/google/brain_autorl/tree/main/evolving_rl)
* Evolution
  * Framework: [[Algorithm](https://github.com/google/pyglove/blob/main/docs/notebooks/intro/search/evolution_algorithm.ipynb)]
    [[Ops](https://github.com/google/pyglove/blob/main/docs/notebooks/intro/search/evolution_ops.ipynb)]
    [[Fine Control](https://github.com/google/pyglove/blob/main/docs/notebooks/intro/search/evolution_scheduling.ipynb)]
  * [Travelling Salesman Problem](https://github.com/google/pyglove/blob/main/docs/notebooks/evolution/tsp.ipynb)
  * [One-Max Problem](https://github.com/google/pyglove/blob/main/docs/notebooks/evolution/onemax.ipynb)
  * [Symbolic function regression with `pg.mutfun`](https://github.com/google/pyglove/blob/main/docs/notebooks/evolution/function_regression.ipynb)

* Machine Learning
  * [Scalably exchanging ML ideas](https://github.com/google/pyglove/blob/main/docs/notebooks/ml/efficiently_exchange_ml_ideas_as_code.ipynb)
  * [Symbolic Machine Learning](https://github.com/google/pyglove/blob/main/docs/notebooks/ml/symbolic_ml.ipynb)
  * [Symbolic Neural Modeling](https://github.com/google/pyglove/blob/main/docs/notebooks/ml/neural_modeling.ipynb)

* Advanced Python Programming
  * [Sticky Notes: A mini Domain-specific Language](https://github.com/google/pyglove/blob/main/docs/notebooks/python/sticky_notes.ipynb)
  * [Interactive SVG: Components for Direct Manipulation](https://github.com/google/pyglove/blob/main/docs/notebooks/python/interactive_svg.ipynb)
  * [Where is the Duck: Developing Context-aware Component](https://github.com/google/pyglove/blob/main/docs/notebooks/python/where_is_the_duck.ipynb)

## Citing PyGlove

```
@inproceedings{peng2020pyglove,
  title={PyGlove: Symbolic programming for automated machine learning},
  author={Peng, Daiyi and Dong, Xuanyi and Real, Esteban and Tan, Mingxing and Lu, Yifeng and Bender, Gabriel and Liu, Hanxiao and Kraft, Adam and Liang, Chen and Le, Quoc},
  booktitle={Advances in Neural Information Processing Systems (NeurIPS)},
  volume={33},
  pages={96--108},
  year={2020}
}
```

*Disclaimer: this is not an officially supported Google product.*

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/google/pyglove",
    "name": "pyglove",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ai machine learning automl mutable symbolic framework meta-programming",
    "author": "PyGlove Authors",
    "author_email": "pyglove-authors@google.com",
    "download_url": "https://files.pythonhosted.org/packages/75/5d/4801e02b5ec6fac86936d354e46dd8574db7203c184f8a3e6a1199caf4f2/pyglove-0.4.4.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n<img src=\"https://raw.githubusercontent.com/google/pyglove/main/docs/_static/logo_light.svg#gh-light-mode-only\" width=\"320px\" alt=\"logo\"></img>\n\n</div>\n\n# PyGlove: Manipulating Python Programs\n\n[![PyPI version](https://badge.fury.io/py/pyglove.svg)](https://badge.fury.io/py/pyglove)\n[![codecov](https://codecov.io/gh/google/pyglove/branch/main/graph/badge.svg)](https://codecov.io/gh/google/pyglove)\n![pytest](https://github.com/google/pyglove/actions/workflows/ci.yaml/badge.svg)\n\n[**Getting started**](#hello-pyglove)\n| [**Installation**](#install)\n| [**Examples**](#examples)\n| [**Reference docs**](https://pyglove.readthedocs.io/)\n\n## What is PyGlove\n\nPyGlove is a general-purpose library for Python object manipulation.\nIt introduces symbolic object-oriented programming to Python, allowing\ndirect manipulation of objects that makes meta-programs much easier to write.\nIt has been used to handle complex machine learning scenarios, such as AutoML,\nas well as facilitating daily programming tasks with extra flexibility.\n\nPyGlove is lightweight and has very few dependencies beyond the Python interpreter.\nIt provides:\n\n* A mutable symbolic object model for Python;\n* A rich set of operations for Python object manipulation;\n* A solution for automatic search of better Python programs, including:\n  * An easy-to-use API for dropping search into an arbitrary pre-existing Python\n    program;\n  * A set of powerful search primitives for defining the search space;\n  * A library of search algorithms ready to use, and a framework for developing\n    new search algorithms;\n  * An API to interface with any distributed infrastructure (e.g. [Open Source Vizier](https://oss-vizier.readthedocs.io/en/latest/advanced_topics/pyglove/vizier_as_backend.html)) for such search.\n\nIt's commonly used in:\n\n* Automated machine learning (AutoML);\n* Evolutionary computing;\n* Machine learning for large teams (evolving and sharing ML code, reusing\n  ML techniques, etc.);\n* Daily programming tasks in Python (advanced binding capabilities, mutability,\n  etc.).\n\nPyGlove has been [published](https://proceedings.neurips.cc/paper/2020/file/012a91467f210472fab4e11359bbfef6-Paper.pdf)\nat NeurIPS 2020. It is widely used within [Alphabet](https://abc.xyz/), including Google Research, Google Cloud, Youtube and Waymo.\n\nPyGlove is developed by Daiyi Peng and colleagues in [Google Brain Team](https://research.google/teams/brain/).\n\n\n## Hello PyGlove\n\n```python\nimport pyglove as pg\n\n@pg.symbolize\nclass Hello:\n  def __init__(self, subject):\n    self._greeting = f'Hello, {subject}!'\n\n  def greet(self):\n    print(self._greeting)\n\n\nhello = Hello('World')\nhello.greet()\n```\n> Hello, World!\n\n```python\nhello.rebind(subject='PyGlove')\nhello.greet()\n```\n> Hello, PyGlove!\n\n```python\nhello.rebind(subject=pg.oneof(['World', 'PyGlove']))\nfor h in pg.iter(hello):\n  h.greet()\n```\n> Hello, World!<br>\n> Hello, PyGlove!\n\n## Install\n\n```\npip install pyglove\n```\n\nOr install nightly build with:\n\n```\npip install pyglove --pre\n```\n\n## Examples\n\n* AutoML\n  * [Neural Architecture Search on MNIST](https://github.com/google/pyglove/tree/main/examples/automl/mnist)\n  * [NAS-Bench-101](https://github.com/google/pyglove/tree/main/examples/automl/nasbench)\n  * [NATS-Bench](https://github.com/google/pyglove/tree/main/examples/automl/natsbench)\n  * [Evolving Reinforcement Learning Algorithms](https://github.com/google/brain_autorl/tree/main/evolving_rl)\n* Evolution\n  * Framework: [[Algorithm](https://github.com/google/pyglove/blob/main/docs/notebooks/intro/search/evolution_algorithm.ipynb)]\n    [[Ops](https://github.com/google/pyglove/blob/main/docs/notebooks/intro/search/evolution_ops.ipynb)]\n    [[Fine Control](https://github.com/google/pyglove/blob/main/docs/notebooks/intro/search/evolution_scheduling.ipynb)]\n  * [Travelling Salesman Problem](https://github.com/google/pyglove/blob/main/docs/notebooks/evolution/tsp.ipynb)\n  * [One-Max Problem](https://github.com/google/pyglove/blob/main/docs/notebooks/evolution/onemax.ipynb)\n  * [Symbolic function regression with `pg.mutfun`](https://github.com/google/pyglove/blob/main/docs/notebooks/evolution/function_regression.ipynb)\n\n* Machine Learning\n  * [Scalably exchanging ML ideas](https://github.com/google/pyglove/blob/main/docs/notebooks/ml/efficiently_exchange_ml_ideas_as_code.ipynb)\n  * [Symbolic Machine Learning](https://github.com/google/pyglove/blob/main/docs/notebooks/ml/symbolic_ml.ipynb)\n  * [Symbolic Neural Modeling](https://github.com/google/pyglove/blob/main/docs/notebooks/ml/neural_modeling.ipynb)\n\n* Advanced Python Programming\n  * [Sticky Notes: A mini Domain-specific Language](https://github.com/google/pyglove/blob/main/docs/notebooks/python/sticky_notes.ipynb)\n  * [Interactive SVG: Components for Direct Manipulation](https://github.com/google/pyglove/blob/main/docs/notebooks/python/interactive_svg.ipynb)\n  * [Where is the Duck: Developing Context-aware Component](https://github.com/google/pyglove/blob/main/docs/notebooks/python/where_is_the_duck.ipynb)\n\n## Citing PyGlove\n\n```\n@inproceedings{peng2020pyglove,\n  title={PyGlove: Symbolic programming for automated machine learning},\n  author={Peng, Daiyi and Dong, Xuanyi and Real, Esteban and Tan, Mingxing and Lu, Yifeng and Bender, Gabriel and Liu, Hanxiao and Kraft, Adam and Liang, Chen and Le, Quoc},\n  booktitle={Advances in Neural Information Processing Systems (NeurIPS)},\n  volume={33},\n  pages={96--108},\n  year={2020}\n}\n```\n\n*Disclaimer: this is not an officially supported Google product.*\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "PyGlove: A library for manipulating Python objects.",
    "version": "0.4.4",
    "project_urls": {
        "Homepage": "https://github.com/google/pyglove"
    },
    "split_keywords": [
        "ai",
        "machine",
        "learning",
        "automl",
        "mutable",
        "symbolic",
        "framework",
        "meta-programming"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0ebd6e5db8f7ed2f7547d4133f1e10448dabf14e6f1816839c70189f1f2419a9",
                "md5": "fdacb03ff1d4ac9e0d4cf9ec5d2886f6",
                "sha256": "a3dee8f261bdd070b0833fec70d6b986bfc45c5f090740fb6bcf53e097465bc4"
            },
            "downloads": -1,
            "filename": "pyglove-0.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fdacb03ff1d4ac9e0d4cf9ec5d2886f6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 577841,
            "upload_time": "2024-01-04T19:14:46",
            "upload_time_iso_8601": "2024-01-04T19:14:46.849189Z",
            "url": "https://files.pythonhosted.org/packages/0e/bd/6e5db8f7ed2f7547d4133f1e10448dabf14e6f1816839c70189f1f2419a9/pyglove-0.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "755d4801e02b5ec6fac86936d354e46dd8574db7203c184f8a3e6a1199caf4f2",
                "md5": "709bbfa99c5a704f464cbf97d953279f",
                "sha256": "a928ccb198d83fcc14cb404cc930d4a6e9e913b740b62fecc3ec6bf3a4c142f6"
            },
            "downloads": -1,
            "filename": "pyglove-0.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "709bbfa99c5a704f464cbf97d953279f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 440533,
            "upload_time": "2024-01-04T19:14:52",
            "upload_time_iso_8601": "2024-01-04T19:14:52.317615Z",
            "url": "https://files.pythonhosted.org/packages/75/5d/4801e02b5ec6fac86936d354e46dd8574db7203c184f8a3e6a1199caf4f2/pyglove-0.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-04 19:14:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "google",
    "github_project": "pyglove",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyglove"
}
        
Elapsed time: 0.25160s