fleet-python 0.2.19__tar.gz → 0.2.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fleet-python might be problematic. Click here for more details.
- {fleet_python-0.2.19 → fleet_python-0.2.20}/PKG-INFO +1 -1
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/sqlite.py +164 -61
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/PKG-INFO +1 -1
- {fleet_python-0.2.19 → fleet_python-0.2.20}/pyproject.toml +1 -1
- {fleet_python-0.2.19 → fleet_python-0.2.20}/LICENSE +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/README.md +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/diff_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/dsl_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_action_log.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_client.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_mcp_anthropic.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_mcp_openai.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_sync.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_task.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_verifier.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/gemini_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/json_tasks_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/nova_act_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/openai_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/openai_simple_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/query_builder_example.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/quickstart.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/base.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/client.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/env/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/env/client.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/exceptions.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/instance/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/instance/base.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/instance/client.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/base.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/browser.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/sqlite.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/tasks.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/verifiers/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/verifiers/bundler.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/verifiers/verifier.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/base.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/client.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/config.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/env/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/env/client.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/exceptions.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/base.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/client.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/models.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/models.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/base.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/browser.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/mcp.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/tasks.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/types.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/__init__.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/bundler.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/code.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/db.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/decorator.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/sql_differ.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/verifier.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/SOURCES.txt +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/dependency_links.txt +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/requires.txt +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/top_level.txt +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/scripts/fix_sync_imports.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/scripts/unasync.py +0 -0
- {fleet_python-0.2.19 → fleet_python-0.2.20}/setup.cfg +0 -0
|
@@ -379,6 +379,9 @@ class SyncSnapshotDiff:
|
|
|
379
379
|
|
|
380
380
|
def _expect_only_targeted(self, allowed_changes: list[dict[str, Any]]):
|
|
381
381
|
"""Optimized version that only queries specific rows mentioned in allowed_changes."""
|
|
382
|
+
import concurrent.futures
|
|
383
|
+
from threading import Lock
|
|
384
|
+
|
|
382
385
|
# Group allowed changes by table
|
|
383
386
|
changes_by_table: dict[str, list[dict[str, Any]]] = {}
|
|
384
387
|
for change in allowed_changes:
|
|
@@ -387,19 +390,12 @@ class SyncSnapshotDiff:
|
|
|
387
390
|
changes_by_table[table] = []
|
|
388
391
|
changes_by_table[table].append(change)
|
|
389
392
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
pk_columns = self._get_primary_key_columns(table)
|
|
397
|
-
|
|
398
|
-
# Extract unique PKs to check
|
|
399
|
-
pks_to_check = {change["pk"] for change in table_changes}
|
|
400
|
-
|
|
401
|
-
# Query only these specific rows from both snapshots
|
|
402
|
-
for pk in pks_to_check:
|
|
393
|
+
errors = []
|
|
394
|
+
errors_lock = Lock()
|
|
395
|
+
|
|
396
|
+
# Function to check a single row
|
|
397
|
+
def check_row(table: str, pk: Any, table_changes: list[dict[str, Any]], pk_columns: list[str]):
|
|
398
|
+
try:
|
|
403
399
|
# Build WHERE clause for this PK
|
|
404
400
|
where_sql = self._build_pk_where_clause(pk_columns, pk)
|
|
405
401
|
|
|
@@ -423,38 +419,99 @@ class SyncSnapshotDiff:
|
|
|
423
419
|
if not _values_equivalent(before_val, after_val):
|
|
424
420
|
# Check if this change is allowed
|
|
425
421
|
if not self._is_field_change_allowed(table_changes, pk, field, after_val):
|
|
426
|
-
|
|
422
|
+
error_msg = (
|
|
427
423
|
f"Unexpected change in table '{table}', "
|
|
428
424
|
f"row {pk}, field '{field}': "
|
|
429
425
|
f"{repr(before_val)} -> {repr(after_val)}"
|
|
430
426
|
)
|
|
427
|
+
with errors_lock:
|
|
428
|
+
errors.append(AssertionError(error_msg))
|
|
429
|
+
return # Stop checking this row
|
|
431
430
|
elif not before_row and after_row:
|
|
432
431
|
# Added row
|
|
433
432
|
if not self._is_row_change_allowed(table_changes, pk, "__added__"):
|
|
434
|
-
|
|
433
|
+
error_msg = f"Unexpected row added in table '{table}': {pk}"
|
|
434
|
+
with errors_lock:
|
|
435
|
+
errors.append(AssertionError(error_msg))
|
|
435
436
|
elif before_row and not after_row:
|
|
436
437
|
# Removed row
|
|
437
438
|
if not self._is_row_change_allowed(table_changes, pk, "__removed__"):
|
|
438
|
-
|
|
439
|
+
error_msg = f"Unexpected row removed from table '{table}': {pk}"
|
|
440
|
+
with errors_lock:
|
|
441
|
+
errors.append(AssertionError(error_msg))
|
|
442
|
+
except Exception as e:
|
|
443
|
+
with errors_lock:
|
|
444
|
+
errors.append(e)
|
|
439
445
|
|
|
440
|
-
#
|
|
441
|
-
|
|
442
|
-
for table in
|
|
443
|
-
if
|
|
446
|
+
# Prepare all row checks
|
|
447
|
+
row_checks = []
|
|
448
|
+
for table, table_changes in changes_by_table.items():
|
|
449
|
+
if self.ignore_config.should_ignore_table(table):
|
|
444
450
|
continue
|
|
451
|
+
|
|
452
|
+
# Get primary key columns once per table
|
|
453
|
+
pk_columns = self._get_primary_key_columns(table)
|
|
445
454
|
|
|
446
|
-
#
|
|
447
|
-
|
|
448
|
-
before_count = before_count_response.rows[0][0] if before_count_response.rows else 0
|
|
449
|
-
|
|
450
|
-
after_count_response = self.after.resource.query(f"SELECT COUNT(*) FROM {table}")
|
|
451
|
-
after_count = after_count_response.rows[0][0] if after_count_response.rows else 0
|
|
455
|
+
# Extract unique PKs to check
|
|
456
|
+
pks_to_check = {change["pk"] for change in table_changes}
|
|
452
457
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
+
for pk in pks_to_check:
|
|
459
|
+
row_checks.append((table, pk, table_changes, pk_columns))
|
|
460
|
+
|
|
461
|
+
# Execute row checks in parallel
|
|
462
|
+
if row_checks:
|
|
463
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
|
464
|
+
futures = [
|
|
465
|
+
executor.submit(check_row, table, pk, table_changes, pk_columns)
|
|
466
|
+
for table, pk, table_changes, pk_columns in row_checks
|
|
467
|
+
]
|
|
468
|
+
concurrent.futures.wait(futures)
|
|
469
|
+
|
|
470
|
+
# Check for errors from row checks
|
|
471
|
+
if errors:
|
|
472
|
+
raise errors[0]
|
|
473
|
+
|
|
474
|
+
# Now check tables not mentioned in allowed_changes to ensure no changes
|
|
475
|
+
all_tables = set(self.before.tables()) | set(self.after.tables())
|
|
476
|
+
tables_to_verify = []
|
|
477
|
+
|
|
478
|
+
for table in all_tables:
|
|
479
|
+
if table not in changes_by_table and not self.ignore_config.should_ignore_table(table):
|
|
480
|
+
tables_to_verify.append(table)
|
|
481
|
+
|
|
482
|
+
# Function to verify no changes in a table
|
|
483
|
+
def verify_no_changes(table: str):
|
|
484
|
+
try:
|
|
485
|
+
# For tables with no allowed changes, just check row counts
|
|
486
|
+
before_count_response = self.before.resource.query(f"SELECT COUNT(*) FROM {table}")
|
|
487
|
+
before_count = before_count_response.rows[0][0] if before_count_response.rows else 0
|
|
488
|
+
|
|
489
|
+
after_count_response = self.after.resource.query(f"SELECT COUNT(*) FROM {table}")
|
|
490
|
+
after_count = after_count_response.rows[0][0] if after_count_response.rows else 0
|
|
491
|
+
|
|
492
|
+
if before_count != after_count:
|
|
493
|
+
error_msg = (
|
|
494
|
+
f"Unexpected change in table '{table}': "
|
|
495
|
+
f"row count changed from {before_count} to {after_count}"
|
|
496
|
+
)
|
|
497
|
+
with errors_lock:
|
|
498
|
+
errors.append(AssertionError(error_msg))
|
|
499
|
+
except Exception as e:
|
|
500
|
+
with errors_lock:
|
|
501
|
+
errors.append(e)
|
|
502
|
+
|
|
503
|
+
# Execute table verification in parallel
|
|
504
|
+
if tables_to_verify:
|
|
505
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
|
506
|
+
futures = [
|
|
507
|
+
executor.submit(verify_no_changes, table)
|
|
508
|
+
for table in tables_to_verify
|
|
509
|
+
]
|
|
510
|
+
concurrent.futures.wait(futures)
|
|
511
|
+
|
|
512
|
+
# Final error check
|
|
513
|
+
if errors:
|
|
514
|
+
raise errors[0]
|
|
458
515
|
|
|
459
516
|
return self
|
|
460
517
|
|
|
@@ -500,6 +557,9 @@ class SyncSnapshotDiff:
|
|
|
500
557
|
def _expect_no_changes(self):
|
|
501
558
|
"""Efficiently verify that no changes occurred between snapshots using row counts."""
|
|
502
559
|
try:
|
|
560
|
+
import concurrent.futures
|
|
561
|
+
from threading import Lock
|
|
562
|
+
|
|
503
563
|
# Get all tables from both snapshots
|
|
504
564
|
before_tables = set(self.before.tables())
|
|
505
565
|
after_tables = set(self.after.tables())
|
|
@@ -516,41 +576,84 @@ class SyncSnapshotDiff:
|
|
|
516
576
|
if not self.ignore_config.should_ignore_table(table):
|
|
517
577
|
raise AssertionError(f"Unexpected table removed: {table}")
|
|
518
578
|
|
|
519
|
-
#
|
|
579
|
+
# Prepare tables to check
|
|
580
|
+
tables_to_check = []
|
|
520
581
|
all_tables = before_tables | after_tables
|
|
521
582
|
for table in all_tables:
|
|
522
|
-
if self.ignore_config.should_ignore_table(table):
|
|
523
|
-
|
|
583
|
+
if not self.ignore_config.should_ignore_table(table):
|
|
584
|
+
tables_to_check.append(table)
|
|
585
|
+
|
|
586
|
+
# If no tables to check, we're done
|
|
587
|
+
if not tables_to_check:
|
|
588
|
+
return self
|
|
589
|
+
|
|
590
|
+
# Use ThreadPoolExecutor to parallelize count queries
|
|
591
|
+
# We use threads instead of processes since the queries are I/O bound
|
|
592
|
+
errors = []
|
|
593
|
+
errors_lock = Lock()
|
|
594
|
+
tables_needing_verification = []
|
|
595
|
+
verification_lock = Lock()
|
|
596
|
+
|
|
597
|
+
def check_table_counts(table: str):
|
|
598
|
+
"""Check row counts for a single table."""
|
|
599
|
+
try:
|
|
600
|
+
# Get row counts from both snapshots
|
|
601
|
+
before_count = 0
|
|
602
|
+
after_count = 0
|
|
524
603
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
604
|
+
if table in before_tables:
|
|
605
|
+
before_count_response = self.before.resource.query(f"SELECT COUNT(*) FROM {table}")
|
|
606
|
+
before_count = before_count_response.rows[0][0] if before_count_response.rows else 0
|
|
607
|
+
|
|
608
|
+
if table in after_tables:
|
|
609
|
+
after_count_response = self.after.resource.query(f"SELECT COUNT(*) FROM {table}")
|
|
610
|
+
after_count = after_count_response.rows[0][0] if after_count_response.rows else 0
|
|
532
611
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
612
|
+
if before_count != after_count:
|
|
613
|
+
error_msg = (
|
|
614
|
+
f"Unexpected change in table '{table}': "
|
|
615
|
+
f"row count changed from {before_count} to {after_count}"
|
|
616
|
+
)
|
|
617
|
+
with errors_lock:
|
|
618
|
+
errors.append(AssertionError(error_msg))
|
|
619
|
+
elif before_count > 0 and before_count <= 1000:
|
|
620
|
+
# Mark for detailed verification
|
|
621
|
+
with verification_lock:
|
|
622
|
+
tables_needing_verification.append(table)
|
|
623
|
+
|
|
624
|
+
except Exception as e:
|
|
625
|
+
with errors_lock:
|
|
626
|
+
errors.append(e)
|
|
627
|
+
|
|
628
|
+
# Execute count checks in parallel
|
|
629
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
|
630
|
+
futures = [executor.submit(check_table_counts, table) for table in tables_to_check]
|
|
631
|
+
concurrent.futures.wait(futures)
|
|
632
|
+
|
|
633
|
+
# Check if any errors occurred during count checking
|
|
634
|
+
if errors:
|
|
635
|
+
# Raise the first error
|
|
636
|
+
raise errors[0]
|
|
637
|
+
|
|
638
|
+
# Now verify small tables for data changes (also in parallel)
|
|
639
|
+
if tables_needing_verification:
|
|
640
|
+
verification_errors = []
|
|
536
641
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
# This is a reasonable assumption for expect_only([])
|
|
553
|
-
pass
|
|
642
|
+
def verify_table(table: str):
|
|
643
|
+
"""Verify a single table's data hasn't changed."""
|
|
644
|
+
try:
|
|
645
|
+
self._verify_table_unchanged(table)
|
|
646
|
+
except AssertionError as e:
|
|
647
|
+
with errors_lock:
|
|
648
|
+
verification_errors.append(e)
|
|
649
|
+
|
|
650
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
|
|
651
|
+
futures = [executor.submit(verify_table, table) for table in tables_needing_verification]
|
|
652
|
+
concurrent.futures.wait(futures)
|
|
653
|
+
|
|
654
|
+
# Check if any errors occurred during verification
|
|
655
|
+
if verification_errors:
|
|
656
|
+
raise verification_errors[0]
|
|
554
657
|
|
|
555
658
|
return self
|
|
556
659
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|