{"id":21683751,"url":"https://github.com/open-eo/openeo-pg-parser-networkx","last_synced_at":"2026-01-17T23:29:40.322Z","repository":{"id":63707126,"uuid":"568935637","full_name":"Open-EO/openeo-pg-parser-networkx","owner":"Open-EO","description":"Parse OpenEO process graphs from JSON to traversible Python objects.","archived":false,"fork":false,"pushed_at":"2025-01-29T10:23:23.000Z","size":1231,"stargazers_count":5,"open_issues_count":6,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-11T17:46:00.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Open-EO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-21T18:18:39.000Z","updated_at":"2025-01-29T10:23:27.000Z","dependencies_parsed_at":"2023-10-15T20:10:50.991Z","dependency_job_id":"f5272e85-f1a9-4c00-b1bc-be84157f1432","html_url":"https://github.com/Open-EO/openeo-pg-parser-networkx","commit_stats":{"total_commits":149,"total_committers":7,"mean_commits":"21.285714285714285","dds":0.4899328859060402,"last_synced_commit":"fd9fb5577b1c6c1e620448d5ce4f80d94dbc5f32"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-EO%2Fopeneo-pg-parser-networkx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-EO%2Fopeneo-pg-parser-networkx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-EO%2Fopeneo-pg-parser-networkx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-EO%2Fopeneo-pg-parser-networkx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Open-EO","download_url":"https://codeload.github.com/Open-EO/openeo-pg-parser-networkx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537009,"owners_count":21120690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T16:13:22.194Z","updated_at":"2025-04-12T07:51:47.919Z","avatar_url":"https://github.com/Open-EO.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenEO Process Graph Parser (Python \u0026 networkx)\n![PyPI - Status](https://img.shields.io/pypi/status/openeo-pg-parser-networkx)\n![PyPI](https://img.shields.io/pypi/v/openeo-pg-parser-networkx)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/openeo-pg-parser-networkx)\n[![codecov](https://codecov.io/github/Open-EO/openeo-pg-parser-networkx/branch/main/graph/badge.svg?token=KEAKFB8AFX)](https://codecov.io/github/Open-EO/openeo-pg-parser-networkx)\n\nPython package to parse OpenEO process graphs from raw JSON into fully traversible [`networkx`](https://github.com/networkx/networkx) graph objects.\nThis package is an evolution of the [openeo-pg-parser-python](https://github.com/Open-EO/openeo-pg-parser-python) package.\n\n## Installation\nThis package can be installed with pip:\n\n```\npip install openeo-pg-parser-networkx\n```\n\nTo enable plotting also install the `plot` extra:\n```\npip install openeo-pg-parser-networkx[plot]\n```\n\nCurrently Python versions 3.9-3.11 are supported.\n\n## Basic usage\n(An example notebook of using `openeo-pg-parser-networkx` together with a process implementation source like [`openeo-processes-dask`](https://github.com/Open-EO/openeo-processes-dask) can be found in `openeo-pg-parser-networkx/examples/01_minibackend_demo.ipynb`.)\n\n**Parse a JSON OpenEO process graph:**\n\n```\nfrom openeo_pg_parser_networkx import OpenEOProcessGraph\n\nEVI_GRAPH_PATH = \"../tests/data/graphs/pg-evi-example.json\"\n\nparsed_graph = OpenEOProcessGraph.from_file(EVI_GRAPH_PATH)\n```\n\n```\n\u003e Deserialised process graph into nested structure\n\u003e Walking node root-7ecd43ed-b694-4a18-8805-eb366d277c8e\n\u003e Walking node mintime-7ecd43ed-b694-4a18-8805-eb366d277c8e\n\u003e Walking node min-80d5faba-c298-4d2f-82f5-be06ee417565\n\u003e Walking node evi-7ecd43ed-b694-4a18-8805-eb366d277c8e\n\u003e Walking node m3-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node div-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node sub-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node nir-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node red-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node sum-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node nir-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node m1-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node red-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node m2-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node blue-657ee106-6571-4509-a1cf-59f212286011\n\u003e Walking node load_collection-7ecd43ed-b694-4a18-8805-eb366d277c8e\n```\n\n**Plot it:**\n\n```\nparsed_graph.plot()\n```\n\n![example process graph](./examples/images/reduce_evi.png)\n\nTo execute a process graph, `OpenEOProcessGraph` needs to know which Python code to call for each of the nodes in the graph. This information is provided by a \"process registry\", which is basically a dictionary that maps each `process_id` to its actual Python implementation as a `Callable`.\n\n**Register process implementations to a \"process registry\":**\n\nThe `ProcessRegistry` object also allows registering wrapper functions that will be wrapped around each registered process implementation.\nSee [openeo-processes-dask](https://github.com/Open-EO/openeo-processes-dask/blob/main/openeo_processes_dask/core.py) for an example of a wrapper function that resolves incoming parameters.\n\n```\nfrom openeo_pg_parser_networkx import ProcessRegistry\n\nfrom openeo_processes_dask.process_implementations import apply, ndvi, multiply, load_collection, save_result\nfrom openeo_processes_dask.core import process\n\n# `process` is wrapped around each registered implementation\nprocess_registry = ProcessRegistry(wrap_funcs=[process])\n\nprocess_registry[\"apply\"] =  apply\nprocess_registry[\"ndvi\"] =  ndvi\nprocess_registry[\"multiply\"] =  multiply\nprocess_registry[\"load_collection\"] =  load_collection\nprocess_registry[\"save_result\"] =  save_result\n\n\n```\nThe `ProcessRegistry` also allows use of namespaces by using a tuple as a key instead of a single value.\nIf using a single value the default namespace is \"predefined\".\n\nAddressing entire namespaces can be done by using None as the value for process_id.\n\n```\nprocess_registry[\"namespace\", \"process_id\"] = process\nprocess_registry[\"namespace\", None] = processes\n\n```\nThis logic can be extended to all functionalities.\n\n```\nprocess = process_registry[\"namespace\", \"process_id\"] # gets the single process named \"process_id\" in the namespace \"namespace\"\nprocesses = process_registry[\"namespace\", None] # gets the entire namespace \"namespace\"\n\n\ndel process_registry[\"namespace\", \"process_id\"] # deletes the single process named \"process_id\" in the namespace \"namespace\"\ndel process_registry[\"namespace\", None] # deletes the entire namespace \"namespace\"\n\n```\n\n\n\n**Build an executable callable from the process graph:**\n\n```\npg_callable = parsed_graph.to_callable(process_registry=process_registry)\n```\n\n**Execute that callable like a normal Python function:**\n\n```\npg_callable\n```\n\n```\n\u003e Running process load_collection\n\u003e Running process apply\n\u003e ...\n```\n\n## Development environment\n`openeo-pg-parser-networkx` requires poetry `\u003e1.2`, see their [docs](https://python-poetry.org/docs/#installation) for installation instructions.\n\nTo setup the python venv and install this project into it run:\n```\npoetry install\n```\n\nTo add a new core dependency run:\n```\npoetry add some_new_dependency\n```\n\nTo add a new development dependency run:\n```\npoetry add some_new_dependency --group dev\n```\n\nTo run the test suite run:\n```\npoetry run python -m pytest\n```\n\n\n\n\nNote that you can also use the virtual environment that's generated by poetry as the kernel for the ipynb notebooks.\n\n### Pre-commit hooks\nThis repo makes use of [pre-commit](https://pre-commit.com/) hooks to enforce linting \u0026 a few sanity checks.\nIn a fresh development setup, install the hooks using `poetry run pre-commit install`.\nThese will then automatically be checked against your changes before making the commit.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-eo%2Fopeneo-pg-parser-networkx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-eo%2Fopeneo-pg-parser-networkx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-eo%2Fopeneo-pg-parser-networkx/lists"}