-
Notifications
You must be signed in to change notification settings - Fork 37
feat: add human-readable duration format support for reservation timeouts #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add human-readable duration format support for reservation timeouts #772
Conversation
0ab473f to
a5bcf9d
Compare
pedro-avalos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating the PR. I just had a chance to look over your changes and have left some comments
|
Also, make sure to sign the CLA with your GitHub email: https://ubuntu.com/legal/contributors |
I have signed the CLA by submitting the form using the provided link. Thank you, @pedro-avalos for taking the time to review my PR. Please let me know if you have any further questions. Cheers. |
ee259e2 to
0293c93
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #772 +/- ##
=======================================
Coverage 64.03% 64.04%
=======================================
Files 94 94
Lines 7889 7905 +16
Branches 758 760 +2
=======================================
+ Hits 5052 5063 +11
- Misses 2691 2695 +4
- Partials 146 147 +1
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@pedro-avalos, it appears that the CI checks are failing due to a repository policy compliance check. Can you kindly take a look? I was able to pass all the tests running locally. |
rene-oromtz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the modifications suggested by Pedro!
I added other nitpicks and suggestions I think can benefit the code, please let me know your thoughts on this.
Also, FYI, just a heads up, the common module is not currently automatically versioned, could you please also increase the version to 1.1.3 in pyproject.yaml? This might require a uv sync in common and server modules to use this new version.
Regarding the CI tests runs, I believe we will need to manually trigger the CI run but this needs to be done after the initial approval
@rene-oromtz Thank you for the thorough and practical feedback! I've addressed all your suggestions. All 104 server tests pass, including the new duration format tests I put in. Please let me know if you have further questions/queries. Cheers. |
d1632f9 to
293ad9d
Compare
|
Thank you for adding the suggested changes! Just one last thing, can you please rebase this branch with latest changes from main? There are conflicts related to Besides that, it looks good to me! Thanks again |
293ad9d to
3303c99
Compare
Hey @rene-oromtz Thank you for catching that! I've successfully rebased the branch with the latest changes from main. Please let me know if you have any questions. Cheers. |
Add support for human-readable duration formats (e.g., "2h30m", "5h", "4d") in reservation timeout fields, while maintaining backward compatibility with integer seconds. Features: - Parse duration strings with s/m/h/d suffixes and full words - Support combined formats like "1h30m" or "2d5h30m" - Comprehensive validation and error handling - Server-only implementation per maintainer guidance - Integration tests with job submission validation - Moved tests to component-level structure for consistency - Optimized parsing logic and removed redundant checks Addresses reviewer feedback from Pedro and Rene: - Simplified regex pattern and optimized negative number checks - Updated to proper reStructuredText docstring format - Bumped common module version to 1.1.3 with editable dependency - Added practical parametrized tests in server/tests/test_v1.py Fixes: canonical#121 (CERTTF-586)
62a8a2b to
76f660c
Compare
|
The PR Checks need approvals to run. CC: @rene-oromtz |
rene-oromtz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit Test are now passed! Thanks again for taking the time to contribute to this repo and for making the modification suggested by reviewers.
Thank you, @rene-oromtz, for taking the time to review my Pull request. I think I might need approval from @pedro-avalos, as he requested changes as well. Testflinger was very helpful in my previous job for setting up hardware test lab automation. I am happy to contribute my time to improve this project. :) I also have another Pull Request for a feature that might be useful. #774. Kindly take a look when you have some free time. Cheers. |
pedro-avalos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes, and thank you @rene-oromtz for taking this PR up while I was out of the office.
Description
This PR adds support for human-readable duration formats (e.g.,
2h30m,5h,30m) for reservation timeouts in job definitions and API requests, while maintaining full backward compatibility with the existing integer seconds format.Problem solved: Users currently need to manually calculate seconds for reservation timeouts (e.g., calculating that 2.5 hours = 9000 seconds), making job definitions less readable and error-prone.
Implementation approach:
testflinger-commonthat handles various time units (s/m/h/d)DurationFieldto server schema for automatic parsing and validationResolved issues
Fixes #121 (CERTTF-586)
Documentation
docs/reference/test-phases.rstcorrectly documents server-side duration format usageWeb service API changes
Schema changes:
ReserveData.timeoutfield to accept both integers and duration stringsDurationFieldfor automatic parsing:"2h30m"→9000seconds/v1/jobendpoint enhancedRequest/Response examples:
Tests
Testing performed:
Test commands to verify:
Examples of supported formats:
30s,30sec(30 seconds)30m,30min(30 minutes)5h,5hour(5 hours)4d,4day(4 days)2h30m(2 hours 30 minutes)1d5h30m(1 day 5 hours 30 minutes)Usage in job definitions:
Notes
This implementation focuses on server-side parsing to avoid snapcraft packaging limitations while still providing the core benefit of human-readable duration formats in job definitions and API requests.