Skip to content

Add list of available places#1581

Merged
Emantor merged 1 commit intolabgrid-project:masterfrom
istepic:available-places
Feb 26, 2025
Merged

Add list of available places#1581
Emantor merged 1 commit intolabgrid-project:masterfrom
istepic:available-places

Conversation

@istepic
Copy link

@istepic istepic commented Jan 27, 2025

Description

Clients sometimes want to know which places are available before acquiring the place.

Checklist

  • Original documentation for the feature already covers this PR, documented on command line, as --acquired.
  • Tests for the feature, no, it's a simple change
  • PR has been tested

Testing:

$ labgrid-client places
target-d-8F94FBAC4EC2DAB50539F2499000055A
target-d-8F94FBAC4EC2DAB50539F299900003D5
$ labgrid-client places --acquired
target-d-8F94FBAC4EC2DAB50539F299900003D5
$ labgrid-client places --available
target-d-8F94FBAC4EC2DAB50539F2499000055A
$ labgrid-client places --help
usage: labgrid-client places [-h] [-a] [-l] [--sort-last-changed]

options:
  -h, --help           show this help message and exit
  -a, --acquired
  -l, --available
  --sort-last-changed  sort by last changed date (oldest first)

@Bastian-Krause
Copy link
Member

I think "available" does not really fit the labgrid lingo, maybe "released" or "unlocked" are better candidates.

@istepic istepic closed this Feb 4, 2025
@istepic istepic reopened this Feb 4, 2025
@istepic
Copy link
Author

istepic commented Feb 4, 2025

@Bastian-Krause makes sense. Done.

$ labgrid-client places -l
target-d-8F94FBAC4EC2DAB50539F2499000055A 
$ labgrid-client places -a
target-d-8F94FBAC4EC2DAB50539F299900003D5 
$ labgrid-client places
target-d-8F94FBAC4EC2DAB50539F2499000055A 
target-d-8F94FBAC4EC2DAB50539F299900003D5 
$ labgrid-client places --released
target-d-8F94FBAC4EC2DAB50539F2499000055A 

@enkiusz
Copy link
Contributor

enkiusz commented Feb 11, 2025

For your consideration, an alternative would be to use:

subparser.add_argument("-a", "--acquired", action=argparse.BooleanOptionalAction, default=None)

and then have --acquired and --no-acquired options used in the loop like so:

        for name, place in places:
            if self.args.acquired is True and place.acquired is None:
                continue
            elif self.args.acquired is False and place.acquired:
                continue
            if self.args.verbose:
                print(f"Place '{name}':")
                place.show(level=1)

This approach does not entail adding a new switch which is like the opposite of --acquired

Copy link
Member

@Bastian-Krause Bastian-Krause left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else looks fine to me.


subparser = subparsers.add_parser("places", aliases=("p",), help="list available places")
subparser.add_argument("-a", "--acquired", action="store_true")
subparser.add_argument("-l", "--released", action="store_true")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why -l?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to -r now.

@codecov
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 55.8%. Comparing base (d35551c) to head (6a9901a).
Report is 32 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/remote/client.py 33.3% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1581     +/-   ##
========================================
- Coverage    55.8%   55.8%   -0.1%     
========================================
  Files         170     170             
  Lines       13380   13383      +3     
========================================
+ Hits         7469    7470      +1     
- Misses       5911    5913      +2     
Flag Coverage Δ
3.10 56.1% <33.3%> (-0.1%) ⬇️
3.11 56.1% <33.3%> (-0.1%) ⬇️
3.12 56.1% <33.3%> (-0.1%) ⬇️
3.13 56.0% <33.3%> (-0.1%) ⬇️
3.9 56.1% <33.3%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@istepic
Copy link
Author

istepic commented Feb 25, 2025

Hi @Bastian-Krause sorry for the slow response and thanks for making the changes. Can we merge this?

Signed-off-by: Ivan Stepic <ivan.stepic@bmw.de>
[bst: renamed shortopt -l -> -r, replaced elif -> if for consistency]
Signed-off-by: Bastian Krause <bst@pengutronix.de>
@Emantor Emantor merged commit 9741924 into labgrid-project:master Feb 26, 2025
9 of 11 checks passed
@Emantor
Copy link
Member

Emantor commented Feb 26, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants