Skip to content

To/from "state" helpers for tmt state files#4486

Open
happz wants to merge 3 commits intomainfrom
to-state-helpers
Open

To/from "state" helpers for tmt state files#4486
happz wants to merge 3 commits intomainfrom
to-state-helpers

Conversation

@happz
Copy link
Contributor

@happz happz commented Jan 14, 2026

tmt saves its state info - step data, test data, guest data, etc. - in YAML format, plent yof *.yaml files in a workdir. It's fine, it's readable by both machines and humans, it works.

It turns out YAML is not necessarily the best format out there, as YAML can be costly to generate when dealing with large structures and large collections.

Two things happen in this PR:

  • To allow some experimentation, TMT_STATE_FORMAT environment variable tells tmt which format to use when storing its data. As of now, only yaml is supported.
  • "to/from JSON" helpers are refactored to align with recent changes to "to/from YAML" helpers, to provide similar function names, annotations and so on, and they are made available for selection via TMT_STATE_FORMAT, making JSON the second supported format for tmt state files.

Moar formats, moar fun!

A set of simple helpers, to_state and from_state is defined, based on the aforementioned envvar, and patch changes all places where tmt stores state on disk to use them instead of {to,from}_yaml. Common.{read,write}_state() will help with that, instead of Common.{read,write}() methods.

Now we can play with different format, and even if we learn the format is not the culprit of ineffective storage of large collections of results, we will have nice and tidy internal API to work with.

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • include a release note

@happz happz requested a review from falconizmi as a code owner January 14, 2026 22:05
@happz happz added this to planning Jan 14, 2026
@happz happz requested a review from dav-pascual as a code owner January 14, 2026 22:05
@happz happz added the ci | full test Pull request is ready for the full test execution label Jan 14, 2026
@github-project-automation github-project-automation bot moved this to backlog in planning Jan 14, 2026
@happz happz moved this from backlog to implement in planning Jan 14, 2026
tmt saves its state info - step data, test data, guest data, etc. - in
YAML format, plent yof `*.yaml` files in a workdir. It's fine, it's
readable by both machines and humans, it works.

It turns out YAML is not necessarily the best format out there, as YAML
can be costly to generate when dealing with large structures and large
collections.

Two things happen in this PR:

* To allow some experimentation, `TMT_STATE_FORMAT` environment
  variable tells tmt which format to use when storing its data. As of
  now, only `yaml` is supported.
* "to/from JSON" helpers are refactored to align with recent changes to
  "to/from YAML" helpers, to provide similar function names,
  annotations and so on, and they are made available for selection via
  `TMT_STATE_FORMAT`, making JSON the second supported format for tmt
  state files.

Moar formats, moar fun!

A set of simple helpers, `to_state` and `from_state` is defined, based
on the aforementioned envvar, and patch changes all places where tmt
stores state on disk to use them instead of `{to,from}_yaml`.
`Common.{read,write}_state()` will help with that, instead of
`Common.{read,write}()` methods.

Now we can play with different format, and even if we learn the format
is not the culprit of ineffective storage of large collections of
results, we will have nice and tidy internal API to work with.
@happz happz moved this from implement to review in planning Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci | full test Pull request is ready for the full test execution

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

1 participant