Skip to content

[Enhancement] Build workflow from dict, add lib versioning#129

Open
zephyrzilla wants to merge 1 commit intomainfrom
scratch/config_dict_and_version
Open

[Enhancement] Build workflow from dict, add lib versioning#129
zephyrzilla wants to merge 1 commit intomainfrom
scratch/config_dict_and_version

Conversation

@zephyrzilla
Copy link
Member

@zephyrzilla zephyrzilla commented Mar 4, 2026

Summary

Adds the ability to build workflows from plain Python dictionaries (in addition to YAML files), and provides a library versioning pipeline across local dev, CI, and PyPI publishing.

Explain the features implemented:

Workflow.from_config() — build workflows from dicts

  • New class method Workflow.from_config(config) accepts a dict or a file path, returning a ready-to-run Workflow instance
  • ConfigLoader improvementsload_and_create() now correctly initialises _is_existing_task, _node_counter, and returns a typed Workflow

Single source of truth versioning

  • sygra/__init__.py is now the sole version authority (__version__ = "2.0.0.post1")
  • Hatchling reads it dynamically via dynamic = ["version"] + [tool.hatch.version] in pyproject.toml
  • Version bumped to 2.0.0.post1 to match the current PyPI release (the 2.0.0 namespace was burned)

make version / make bump-version

  • make version — prints the current version (stdlib python3, no uv run overhead)
  • make bump-version V=X.Y.Z — patches both sygra/__init__.py and [tool.poetry].version atomically, with PEP 440 validation

Publish workflow updates (publish.yml)

  • Dual trigger — fires on push: tags: v* (CLI) and release: published (GitHub UI), with a concurrency group to prevent double-runs
  • Robust version extraction — handles both event types, with/without v prefix, validated against PEP 440
  • PyPI pre-flight check — queries PyPI before building to fail fast if the version is already burned
  • Artifact validation — verifies .whl and .tar.gz filenames contain the correct version before uploading

CI version guards (ci.yml)

  • Tag trigger added — CI now runs on push: tags: v* in addition to branch pushes
  • PEP 440 format check — always validates __version__ format (supports X.Y.Z, X.Y.Z.postN, etc.)
  • Tag & code match — on tagged builds, validates the Git tag matches __version__ before proceeding

Pre-commit version hook

  • New version-check hook validates __version__ is valid PEP 440 on every commit touching sygra/__init__.py

Performance impact (if any):

  • N/A — no runtime performance changes. Build/CI pipelines gain early-exit validation.

How to Test the feature

Test Workflow.from_config():

  1. Run the example script:
    from sygra.workflow import Workflow
    config = {
        "data_config": {"source": {"type": "disk", "file_path": "data.json", "file_format": "json"}},
        "graph_config": {
            "nodes": {"llm_1": {"node_type": "llm", "model": {"name": "gpt-4o"}, "prompt": [{"user": "Hello {text}"}]}},
            "edges": [{"from": "START", "to": "llm_1"}, {"from": "llm_1", "to": "END"}]
        }
    }
    wf = Workflow.from_config(config)
  2. Verify wf.name, wf._is_existing_task, and wf._node_counter are set correctly

Test versioning:

  1. make version: should print 2.0.0.post1
  2. make bump-version V=2.1.0: patches both files, prints next steps
  3. make bump-version V=bad: rejects with PEP 440 error
  4. Revert: make bump-version V=2.0.0.post1

Test CI/publish (dry run):

  1. Push a tag: the CI Validate version format step should pass
  2. The publish workflow should extract the version, check PyPI availability, patch, build, validate artifacts

Screenshots (if applicable)

N/A — backend and CI/CD changes only.

Checklist

  • Lint fixes and unit testing done
  • End to end task testing
  • Documentation updated

@zephyrzilla zephyrzilla requested a review from a team as a code owner March 4, 2026 05:55
from sygra.core.graph.graph_config import GraphConfig # noqa: F401
from sygra.utils import utils
from sygra.workflow import AutoNestedDict
from sygra.workflow import AutoNestedDict # noqa: F401
@zephyrzilla zephyrzilla changed the title feat: build workflow from dict, add lib versioning [Enhancement] Build workflow from dict, add lib versioning Mar 4, 2026
@zephyrzilla zephyrzilla self-assigned this Mar 4, 2026
@zephyrzilla zephyrzilla added the enhancement New feature or request label Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants