Skip to content

FD-74: Add channels(ingest and fetch) and rules to client.#275

Merged
ian-sift merged 24 commits intomainfrom
FD-74
Aug 28, 2025
Merged

FD-74: Add channels(ingest and fetch) and rules to client.#275
ian-sift merged 24 commits intomainfrom
FD-74

Conversation

@ian-sift
Copy link
Contributor

@ian-sift ian-sift commented Jul 23, 2025

Expecting Ailin to review Channels and Ingestion files and Marc to review Rules. (of course welcome to cross review)

Verification:

Channel Fetch

Using run: [NostromoLV426].1753128174.820318 (ID: cb0e1a86-9117-4cba-b69b-2d6787f9d6be)
Found 0 other asset(s): [] for run [NostromoLV426].1753128174.820318 (ID: cb0e1a86-9117-4cba-b69b-2d6787f9d6be)
Found 6 channel(s): ['gpio', 'mainmotor.velocity', 'voltage', 'gpio', 'mainmotor.velocity', 'voltage'] for asset NostromoLV426 on run [NostromoLV426].1751491046.788349
Found 2 other channel(s): ['log', 'vehicle_state'] for asset NostromoLV426 on run [NostromoLV426].1751491046.788349
Channel data for gpio has 4 points
Getting data for multiple channels:
0: voltage: 100 points. Avg: 5.99
1: mainmotor.velocity: 29 points. Avg: 5.586206896551724
Start time: 2025-07-02 21:17:28.878926+00:00, End time: 2025-07-02 21:18:24.878785+00:00
2: gpio.12v: 89 points. Avg: 1.0
3: gpio.charge: 89 points. Avg: 0.7865168539325843
4: gpio.heater: 89 points. Avg: 0.21348314606741572
5: gpio.led: 89 points. Avg: 3.235955056179775

=== Testing cache with varying time ranges ===

Test 1: Exact same time range no run_id (should hit cache)

Test 2: Subset of time range (should hit cache if overlapping)

Test 3: Extended time range earlier (should hit cache for overlapping portion)

Test 4: Different time encompassed range (should hit cache)

Test 5: No time range specified (should miss cache)
0: voltage: 100 points. Avg: 5.02
1: mainmotor.velocity: 100 points. Avg: 5.24
2: gpio.12v: 100 points. Avg: 1.0
3: gpio.charge: 99 points. Avg: 0.8787878787878788
4: gpio.heater: 99 points. Avg: 0.18181818181818182
5: gpio.led: 99 points. Avg: 3.090909090909091

Test 6: No time range specified again (should hit cache)
0: voltage: 200 points. Avg: 5.505
1: mainmotor.velocity: 129 points. Avg: 5.317829457364341
2: gpio.12v: 189 points. Avg: 1.0
3: gpio.charge: 189 points. Avg: 0.8351063829787234
4: gpio.heater: 189 points. Avg: 0.19680851063829788
5: gpio.led: 189 points. Avg: 3.1595744680851063

Test 7: Get data as arrow
0: voltage: 200 points. Avg: 5.505
1: mainmotor.velocity: 129 points. Avg: 5.317829457364341
2: gpio.12v: 189 points. Avg: 1.0
3: gpio.charge: 189 points. Avg: 0.8351063829787234
4: gpio.heater: 189 points. Avg: 0.19680851063829788
5: gpio.led: 189 points. Avg: 3.1595744680851063

=== Cache Performance Summary ===
Original call: 0.2812 seconds
Exact time range no run_id: 0.0038 seconds (73.6x faster)
Subset time range: 0.0029 seconds (96.2x faster)
Extended time range earlier: 0.0686 seconds (4.1x faster)
Different time range: 0.0039 seconds (72.5x faster)
No time range: 0.8357 seconds (3.0x slower)
No time range repeat: 0.0036 seconds (231.4x faster)
Arrow: 0.0138 seconds (3.8x faster)

Channel Ingest

   Deleting previously created runs: [Run(id='d06fd6a9-30c6-4931-87b7-0d7e079c5a82', name='test-run-1753726230.720762', description='A test run created via the API', created_date=datetime.datetime(2025, 7, 28, 18, 10, 30, 811028), modified_date=datetime.datetime(2025, 7, 28, 18, 10, 30, 825254), created_by_user_id='1eba461b-fa36-4e98-8fe8-ff32d3e43a6e', modified_by_user_id='1eba461b-fa36-4e98-8fe8-ff32d3e43a6e', organization_id='dd9f82ef-7805-4b02-9572-ec61b71edde6', start_time=datetime.datetime(2025, 7, 28, 18, 10, 31, 153495), stop_time=datetime.datetime(2025, 7, 28, 18, 11, 21, 133495), tags=['test', 'api-created'], default_report_id='c4bfe06c-4245-44b1-892b-879bdfe93a99', client_key=None, metadata={}, asset_ids=['9f06ddd9-f44c-45b6-a554-cbd2f7d35149'], archived_date=None)]
   Deleting run: test-run-1753726230.720762
2025-07-28 11:12:46,250 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Getting ingestion config id from generated client key 8d85cbd7c4f302bb962bfa5f9b22d8c8658c1a6c7c9fb989960e789b655d6113
2025-07-28 11:12:46,444 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion config cb2850f1-6d84-45b0-a2f7-114996992412 already exists but is not yet in the cache.
2025-07-28 11:12:46,510 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Built new stream for ingestion config cb2850f1-6d84-45b0-a2f7-114996992412
Flow test-flow ingestion config id: cb2850f1-6d84-45b0-a2f7-114996992412, asset: ian-test-asset
Flow highspeed-flow ingestion config id: cb2850f1-6d84-45b0-a2f7-114996992412, asset: ian-test-asset
2025-07-28 11:12:46,511 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Getting ingestion config id from generated client key 3285fd28e95919241e9a717f2e828a402461aed33be9306c5b8a201ec2cca4ac
2025-07-28 11:12:46,511 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread started
2025-07-28 11:12:46,569 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion config 68f27ca2-c90c-4624-bb25-44c4d78f194a already exists but is not yet in the cache.
2025-07-28 11:12:46,626 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Built new stream for ingestion config 68f27ca2-c90c-4624-bb25-44c4d78f194a
Flow new-asset-flow ingestion config id: 68f27ca2-c90c-4624-bb25-44c4d78f194a, asset: test-asset-ian2
2025-07-28 11:12:46,627 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread started
2025-07-28 11:12:47,001 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread sent 1 requests, remaining: 356
2025-07-28 11:12:47,592 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread sent 817 requests, remaining: 101
2025-07-28 11:12:48,090 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - No more requests. Stopping. Sent 0 requests. 0 requests remaining.
2025-07-28 11:12:48,178 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread sent 1378 requests, remaining: 101
2025-07-28 11:12:48,764 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread sent 1939 requests, remaining: 101
2025-07-28 11:12:49,338 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Waiting for ingestion to complete
2025-07-28 11:12:49,338 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread started
2025-07-28 11:12:49,339 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread sent 2500 requests, remaining: 50
2025-07-28 11:12:49,803 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread sent 1 requests, remaining: 0
2025-07-28 11:12:50,378 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - No more requests. Stopping. Sent 2550 requests. 0 requests remaining.
2025-07-28 11:12:50,842 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - No more requests. Stopping. Sent 1 requests. 0 requests remaining.
Restarting ingestion
2025-07-28 11:12:51,898 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Waiting for ingestion to complete
2025-07-28 11:12:51,899 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread started
2025-07-28 11:12:52,369 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - Ingestion thread sent 1 requests, remaining: 0
2025-07-28 11:12:53,404 - sift_client._internal.low_level_wrappers.ingestion - ERROR - Ingestion thread did not finish after 1.5 seconds. Forcing stop.
2025-07-28 11:12:53,411 - sift_client._internal.low_level_wrappers.ingestion - DEBUG - No more requests. Stopping. Sent 1 requests. 0 requests remaining.
Ingestion time: 0:00:04.263716 seconds
Ingested 2650 datapoints
Ingestion rate: 621.52 datapoints/second
Screenshot 2025-07-28 at 11 08 24 AM

Rules

Using asset: NostromoLV426 (ID: a695480e-0069-44b0-ab4b-93e602f743cb)

=== Creating 8 rules with unique suffix: 20250728110645 ===
Created rule: test_rule_20250728110645_0 (ID: 93da24c9-75f2-4337-b1c2-263c426c2146)
Created rule: test_rule_20250728110645_1 (ID: 55875139-cfb2-4603-9fd5-036870ab0f3c)
Created rule: test_rule_20250728110645_2 (ID: 2b0c81b1-95e8-460d-8edc-263fcb8d3baf)
Created rule: test_rule_20250728110645_3 (ID: 628f7856-5c0d-48f2-adeb-fbd4d3d5597a)
Created rule: test_rule_20250728110645_4 (ID: 63b09672-2efd-4084-b6e4-9f06eef7f145)
Created rule: test_rule_20250728110645_5 (ID: 11a4fe67-0c37-4e75-bfb6-0818b5a7f5d4)
Created rule: test_rule_20250728110645_6 (ID: 9c0cf340-afdb-4a43-9035-320808a79fb7)
Created rule: test_rule_20250728110645_7 (ID: a4b10840-cce4-415b-9a2a-0eebc817d1a4)

=== Testing comprehensive update scenarios ===

--- Test 1: Update expression and channel references ---
Updated : expression = $1 > 0.5

--- Test 2: Update description ---
Updated : description = Updated description with more details about velocity-to-voltage ratio monitoring

--- Test 3: Update action ---
Updated : action type = RuleActionType.ANNOTATION
  - annotation type: RuleAnnotationType.PHASE
  - tags: ['updated', 'phase', 'alert']
  - assignee: 1eba461b-fa36-4e98-8fe8-ff32d3e43a6e

--- Test 4: Update name ---
Updated renamed_rule_20250728110645_4 -> renamed_rule_20250728110645_4

--- Test 5: Update multiple fields simultaneously ---
Updated :
  - description: Multi-field update test
  - is_enabled: True
  - version_notes: Updated via multi-field update

--- Test 6: Update with complex expression ---
Updated : complex expression = $1 > 0.3 && $1 < 0.8

--- Test 7: Update action to notification ---

--- Test 8: Update tag_ids and contextual_channels ---
Updated :
  - tag_ids: []
  - contextual_channels: ['temperature', 'pressure']

--- Test 8b: Edge case - Invalid expression test ---
Invalid expression update failed as expected: <AioRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "invalid argument: No valid inputs exist for expression: invalid_expression (39fc204b-f181-45bf-a01c-db15b08e8963)"
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_status:3, grpc_message:"invalid argument: No valid inputs exist for expression: invalid_expression (39fc204b-f181-45bf-a01c-db15b08e8963)"}"
>

--- Test 9: Batch operations demonstration ---
Batch retrieved 8 rules:
  - : $1 > 0.5
  - : $1 > 0.1
  - : $1 > 0.1
  - renamed_rule_20250728110645_4: $1 > 0.1
  - : $1 > 0.1
  - : $1 > 0.3 && $1 < 0.8
  - test_rule_20250728110645_6: $1 > 0.1
  - : $1 > 0.1

--- Test 10: Delete rules ---

=== Test Summary ===
Created: 8 rules
Updated: 8 rules

=== Validation Checks ===
All validation checks passed!

=== Test completed successfully ===

Copy link

@niliayu niliayu left a comment

Choose a reason for hiding this comment

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

Looking really good to me! Mostly superficial feedback but a couple little things I think are worth thinking on a bit

@ian-sift ian-sift requested a review from alexluck-sift July 30, 2025 23:51
Copy link
Collaborator

@alexluck-sift alexluck-sift left a comment

Choose a reason for hiding this comment

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

Generally looks good. A few nomenclature/structure changes to improve consistency and user clarity.

Can we break out the ingestion work into a separate PR?

@ian-sift ian-sift requested a review from alexluck-sift August 6, 2025 16:39
@ian-sift ian-sift requested a review from niliayu August 14, 2025 17:52
Copy link

@niliayu niliayu left a comment

Choose a reason for hiding this comment

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

Looking really good! One nit left on the deps

@ian-sift ian-sift requested a review from niliayu August 20, 2025 18:55
@ian-sift ian-sift requested a review from alexluck-sift August 25, 2025 17:50
Copy link
Collaborator

@alexluck-sift alexluck-sift left a comment

Choose a reason for hiding this comment

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

Resolved comments that have been addressed

alexluck-sift
alexluck-sift previously approved these changes Aug 27, 2025
Copy link
Collaborator

@alexluck-sift alexluck-sift left a comment

Choose a reason for hiding this comment

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

Looks good to merge!

niliayu
niliayu previously approved these changes Aug 27, 2025
Copy link

@niliayu niliayu left a comment

Choose a reason for hiding this comment

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

Looks great! Nice work!

marc-sift
marc-sift previously approved these changes Aug 28, 2025
@ian-sift ian-sift merged commit aa16167 into main Aug 28, 2025
10 checks passed
@ian-sift ian-sift deleted the FD-74 branch August 28, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants