Skip to content

Harmonize place and reservations handling with environment file #1871

@dwagenk

Description

@dwagenk

I've struggeld a bit with the handling of labgrid places and reservations when using an environment configuration file. This is an attempt to find a consensus of what the handling should be so it can be adapted in the implementation and added to the documentation.


Suggestion 1:

Current situation:

With an environment file configured (LG_ENV variable or -c flag) labgrid-client lock and related actions operate on

For labgrid-client actions interacting with a single device (power, io) the LG_PLACE=*|all is treated the same as LG_PLACE= using the main target from the environment file. More complex usages are possible from python and inside tests by using a specific target from the environment configuration.

Since no release containing #1748 was made yet I would not consider this a breaking change.


Suggestion 2:

Current situation:

  • External scripts need to assemble the place tags for a labgrid-client reserve call and can then be used in combination with an LG_PLACE=+ and an environment config like this:
    targets:
      main:
        resources:
          RemotePlace:
            name: !template $LG_PLACE
  • Combining the correct set of reserve arguments and environment files (and possibly also test suites to run) is cumbersome

Integrate reservation handling with the environment configuration file. My goal is to replace the custom handling of the reservation with

export LG_ENV=/path/to/env.yaml
export LG_PLACE=+
source <(labgrid-client reserve --shell --wait)
labgrid-client lock
# run tests e.g. pytest --lg-env $LG_ENV tests
labgrid-client unlock

To archieve this I'd suggest allowing more versatile matching in RemotePlace by allowing a dictionary of place tags and values instead of only name. Following the example in https://labgrid.readthedocs.io/en/latest/usage.html#place-scheduling a environment configuration compatible with any place tagged board=imx6-foo would be:

targets:
  main:
    resources:
      RemotePlace:
        board: imx6-foo

and labgrid-client -c /path/to/env.yaml reserve without any key=value pairs (or explicitely with a flag?) would take the board=imx6-foo from the environment configuration.

For environment configuration files with multiple targets the LG_PLACE handling outlined in suggestion 1 would be taken into account, with

  • LG_PLACE='*'|all -> one reservation per target in the environment file is created, --wait would wait until all of them are available
  • LG_PLACE= (emtpy or unset) -> reservation for target main
  • LG_PLACE=someplacename -> reservation for the target with matching RemotePlace (only works if at least one target sets RemotePlace: {name: someplacename}
  • LG_PLACE=+ -> error or treated identical to empty LG_PLACE

If we agree that this would be an overall improvement I'd continue my work on a proof of concept for this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions