Repository navigation
feat(crud-machine): add machine data classes and result handler - #1175
Closed
Karen Chen (karenychen) wants to merge 1 commit into
Closed
Karen Chen (karenychen) wants to merge 1 commit into
Karen Chen (karenychen) wants to merge 1 commit into
Conversation
First slice of the k8s-cluster-crud-machine perf-test port from ado-telescope. Introduces a new `machine/` python package with the data records and result-persistence decorator that subsequent slices will build on. Differences from ado-telescope's reference k8s package: - OperationNames is a str Enum (was a frozen @DataClass). - MachineOperationResponse.percentile_node_readiness_times is a nested envelope (Dict[str, Dict[str, Any]]) so each percentile carries its target_nodes / elapsed_time_seconds / percentage / success metadata. - save_test_result writes a nested {config, response} payload instead of a flat **-spread that could overwrite overlapping keys. - Persistence failures are swallowed and logged rather than propagated, so test orchestration stays insulated from disk errors. Verification: - pylint 10.00/10 on all touched files. - pytest: 7/7 new tests pass; machine/data_classes.py 100%, machine/result_handler.py 97%. - Full module pytest --cov-fail-under=80 still green (83.67% total).
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces the foundational modules/python/machine/ package for the upcoming k8s-cluster-crud-machine perf-test port, including typed data records and a reusable result-persistence decorator, plus initial unit tests.
Changes:
- Added
MachineConfig,ScaleMachineRequest,MachineOperationResponse, andOperationNamesto formalize the Machine perf-test schema. - Added
@save_test_resultdecorator to persist per-operation results as nested{config, response}JSON blobs. - Added pytest coverage for the new data classes and result handler behavior (including error swallowing).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/python/machine/data_classes.py | Adds core dataclasses and operation-name enum for machine CRUD perf-test schema. |
| modules/python/machine/result_handler.py | Adds decorator to persist per-operation results to JSON files under result_dir. |
| modules/python/machine/init.py | Declares the new machine package. |
| modules/python/tests/test_machine_data_classes.py | Unit tests for defaults/types and enum values in the new dataclasses. |
| modules/python/tests/test_machine_result_handler.py | Unit tests for nested payload persistence, filename suffix selection, and write-error swallowing. |
Comment on lines
+40
to
+44
| op_name = response.operation_name | ||
| suffix = config.machine_name or config.agentpool_name | ||
| timestamp = int(datetime.now(timezone.utc).timestamp()) | ||
| filename = f"{op_name}-{config.cloud}-{config.cluster_name}-{suffix}-{timestamp}.json" | ||
| path = os.path.join(config.result_dir, filename) |
Comment on lines
+41
to
+45
| suffix = config.machine_name or config.agentpool_name | ||
| timestamp = int(datetime.now(timezone.utc).timestamp()) | ||
| filename = f"{op_name}-{config.cloud}-{config.cluster_name}-{suffix}-{timestamp}.json" | ||
| path = os.path.join(config.result_dir, filename) | ||
| os.makedirs(config.result_dir, exist_ok=True) |
Comment on lines
+50
to
+53
| save_info_to_file(payload, path) | ||
| logger.info("Wrote result to %s", path) | ||
| except Exception as exc: # pylint: disable=broad-except | ||
| logger.warning("Failed to save result: %s", exc) |
Contributor
Author
|
Closing per restructure decision. After reviewing gh-telescope's existing CRUD framework (
Will reopen as a new PR series of ~5 PRs once the feature branch has been refactored and validated end-to-end against the staging pipeline. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
First slice of the k8s-cluster-crud-machine Machine API perf-test port from ado-telescope to gh-telescope (tracking issue / project plan:
feat/k8s-cluster-crud-machine).The full feature is being shipped in 11 small, reviewable PRs. This PR is the foundation: it adds the python data records and the result-persistence decorator that every subsequent slice will depend on.
What
New
modules/python/machine/package containing:data_classes.py—MachineConfig,ScaleMachineRequest,MachineOperationResponse,OperationNamesenum.result_handler.py—@save_test_resultdecorator that writes each op's response to disk as JSON.Differences from ado-telescope's reference
k8s/packageOperationNamesis astrEnum (was a frozen@dataclass).MachineOperationResponse.percentile_node_readiness_timesis a nested envelope (Dict[str, Dict[str, Any]]) so each percentile carries itstarget_nodes/elapsed_time_seconds/percentage/successmetadata (matches the ado-golden blob schema atperf-eval/k8s-cluster-crud-machine/main/<id>.json).save_test_resultwrites a nested{config, response}payload instead of a flat**-spreadthat could silently overwrite overlapping keys.Verification
pylint modules/python/machine/* modules/python/tests/test_machine_*.py→ 10.00/10.pytest tests/test_machine_data_classes.py tests/test_machine_result_handler.py→ 7 passed.machine/data_classes.py100%,machine/result_handler.py97%.pytest --cov=. --cov-fail-under=80(full module suite) → 700 passed, 1 skipped, 83.67% total.Subsequent PRs in this series
create_machine_agentpoolscale_machinenon-batch pathscale_machinebatch (BatchPutMachine)