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.

Files changed (72) hide show
  1. {fleet_python-0.2.19 → fleet_python-0.2.20}/PKG-INFO +1 -1
  2. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/sqlite.py +164 -61
  3. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/PKG-INFO +1 -1
  4. {fleet_python-0.2.19 → fleet_python-0.2.20}/pyproject.toml +1 -1
  5. {fleet_python-0.2.19 → fleet_python-0.2.20}/LICENSE +0 -0
  6. {fleet_python-0.2.19 → fleet_python-0.2.20}/README.md +0 -0
  7. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/diff_example.py +0 -0
  8. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/dsl_example.py +0 -0
  9. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example.py +0 -0
  10. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_action_log.py +0 -0
  11. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_client.py +0 -0
  12. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_mcp_anthropic.py +0 -0
  13. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_mcp_openai.py +0 -0
  14. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_sync.py +0 -0
  15. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_task.py +0 -0
  16. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/example_verifier.py +0 -0
  17. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/gemini_example.py +0 -0
  18. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/json_tasks_example.py +0 -0
  19. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/nova_act_example.py +0 -0
  20. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/openai_example.py +0 -0
  21. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/openai_simple_example.py +0 -0
  22. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/query_builder_example.py +0 -0
  23. {fleet_python-0.2.19 → fleet_python-0.2.20}/examples/quickstart.py +0 -0
  24. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/__init__.py +0 -0
  25. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/__init__.py +0 -0
  26. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/base.py +0 -0
  27. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/client.py +0 -0
  28. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/env/__init__.py +0 -0
  29. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/env/client.py +0 -0
  30. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/exceptions.py +0 -0
  31. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/instance/__init__.py +0 -0
  32. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/instance/base.py +0 -0
  33. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/instance/client.py +0 -0
  34. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/__init__.py +0 -0
  35. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/base.py +0 -0
  36. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/browser.py +0 -0
  37. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/resources/sqlite.py +0 -0
  38. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/tasks.py +0 -0
  39. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/verifiers/__init__.py +0 -0
  40. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/verifiers/bundler.py +0 -0
  41. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/_async/verifiers/verifier.py +0 -0
  42. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/base.py +0 -0
  43. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/client.py +0 -0
  44. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/config.py +0 -0
  45. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/env/__init__.py +0 -0
  46. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/env/client.py +0 -0
  47. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/exceptions.py +0 -0
  48. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/__init__.py +0 -0
  49. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/base.py +0 -0
  50. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/client.py +0 -0
  51. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/instance/models.py +0 -0
  52. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/models.py +0 -0
  53. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/__init__.py +0 -0
  54. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/base.py +0 -0
  55. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/browser.py +0 -0
  56. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/resources/mcp.py +0 -0
  57. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/tasks.py +0 -0
  58. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/types.py +0 -0
  59. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/__init__.py +0 -0
  60. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/bundler.py +0 -0
  61. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/code.py +0 -0
  62. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/db.py +0 -0
  63. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/decorator.py +0 -0
  64. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/sql_differ.py +0 -0
  65. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet/verifiers/verifier.py +0 -0
  66. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/SOURCES.txt +0 -0
  67. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/dependency_links.txt +0 -0
  68. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/requires.txt +0 -0
  69. {fleet_python-0.2.19 → fleet_python-0.2.20}/fleet_python.egg-info/top_level.txt +0 -0
  70. {fleet_python-0.2.19 → fleet_python-0.2.20}/scripts/fix_sync_imports.py +0 -0
  71. {fleet_python-0.2.19 → fleet_python-0.2.20}/scripts/unasync.py +0 -0
  72. {fleet_python-0.2.19 → fleet_python-0.2.20}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.19
3
+ Version: 0.2.20
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.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
- # For each table with allowed changes, query only those specific rows
391
- for table, table_changes in changes_by_table.items():
392
- if self.ignore_config.should_ignore_table(table):
393
- continue
394
-
395
- # Get primary key columns
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
- raise AssertionError(
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
- raise AssertionError(f"Unexpected row added in table '{table}': {pk}")
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
- raise AssertionError(f"Unexpected row removed from table '{table}': {pk}")
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
- # Now check tables not mentioned in allowed_changes to ensure no changes
441
- all_tables = set(self.before.tables()) | set(self.after.tables())
442
- for table in all_tables:
443
- if table in changes_by_table or self.ignore_config.should_ignore_table(table):
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
- # For tables with no allowed changes, just check row counts
447
- before_count_response = self.before.resource.query(f"SELECT COUNT(*) FROM {table}")
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
- if before_count != after_count:
454
- raise AssertionError(
455
- f"Unexpected change in table '{table}': "
456
- f"row count changed from {before_count} to {after_count}"
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
- # For each table, compare row counts
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
- continue
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
- # Get row counts from both snapshots
526
- before_count = 0
527
- after_count = 0
528
-
529
- if table in before_tables:
530
- before_count_response = self.before.resource.query(f"SELECT COUNT(*) FROM {table}")
531
- before_count = before_count_response.rows[0][0] if before_count_response.rows else 0
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
- if table in after_tables:
534
- after_count_response = self.after.resource.query(f"SELECT COUNT(*) FROM {table}")
535
- after_count = after_count_response.rows[0][0] if after_count_response.rows else 0
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
- if before_count != after_count:
538
- raise AssertionError(
539
- f"Unexpected change in table '{table}': "
540
- f"row count changed from {before_count} to {after_count}"
541
- )
542
-
543
- # If counts match but there could be modifications, we need to check further
544
- # For now, we'll do a more detailed check only if counts are small
545
- # to avoid performance issues
546
- if before_count > 0 and before_count <= 1000: # Threshold for detailed check
547
- # Do a quick hash check of the data
548
- self._verify_table_unchanged(table)
549
- elif before_count > 1000:
550
- # For large tables, we could sample or use checksums
551
- # For now, we'll trust that count matching means no changes
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fleet-python
3
- Version: 0.2.19
3
+ Version: 0.2.20
4
4
  Summary: Python SDK for Fleet environments
5
5
  Author-email: Fleet AI <nic@fleet.so>
6
6
  License: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "fleet-python"
7
- version = "0.2.19"
7
+ version = "0.2.20"
8
8
  description = "Python SDK for Fleet environments"
9
9
  authors = [
10
10
  {name = "Fleet AI", email = "nic@fleet.so"},
File without changes
File without changes
File without changes