-
Notifications
You must be signed in to change notification settings - Fork 74
Description
Summary
The CI module uses raw string literals for result dictionary keys and API state comparisons. These should be refactored to use constants (or enums where appropriate) for better maintainability and IDE support.
This was identified during PR review feedback from @ottobackwards.
Background
The CI module functions return dictionaries with standardized field names that are consumed by CI/CD pipelines (GitHub Actions outputs, GitLab CI dotenv). Currently these are raw strings:
# nipyapi/ci/get_status.py
result["queued_flowfiles"] = str(agg.flow_files_queued or 0)
result["queued_bytes"] = str(agg.bytes_queued or 0)
result["active_threads"] = str(agg.active_thread_count or 0)Similarly, API state values are compared as raw strings:
if c.component.state == "ENABLED":
if vci.state not in ["UP_TO_DATE", "SYNC_FAILURE"]:
if b.level == "WARNING":Scope
Result field names (~58 instances across 8+ files):
get_status.py- ~30 fields (largest)verify_config.py,configure_inherited_params.py,upload_asset.py,list_registry_flows.py,export_parameters.py, etc.
API state values (used in comparisons):
- Controller states:
ENABLED,DISABLED - Version control states:
UP_TO_DATE,SYNC_FAILURE,LOCALLY_MODIFIED,STALE - Bulletin levels:
WARNING,ERROR - Process group states:
RUNNING,STOPPED
Note: Many API values already have allowed_values validation in the generated OpenAPI models (nipyapi/nifi/models/), so these are stable and well-defined by the NiFi API spec.
Proposed Approach
-
Create
nipyapi/ci/constants.pywith:- Result field name constants (e.g.,
FIELD_QUEUED_FLOWFILES = "queued_flowfiles") - API state constants grouped by category (e.g.,
STATE_ENABLED = "ENABLED")
- Result field name constants (e.g.,
-
Update CI module files to import and use these constants
-
Update tests to use the same constants