ts_shape.loader.timeseries.azure_blob_loader
¤
Classes:
-
AzureBlobFlexibleFileLoader–Load arbitrary file types from Azure Blob Storage under time-structured folders.
-
AzureBlobParquetLoader–Load parquet files from an Azure Blob Storage container filtered by a list of UUIDs.
AzureBlobFlexibleFileLoader
¤
AzureBlobFlexibleFileLoader(container_name: str, *, connection_string: Optional[str] = None, account_url: Optional[str] = None, credential: Optional[object] = None, prefix: str = '', max_workers: int = 8, hour_pattern: str = '{Y}/{m}/{d}/{H}/')
Load arbitrary file types from Azure Blob Storage under time-structured folders.
Designed for containers with paths like: prefix/YYYY/MM/DD/HH/
Methods:
-
fetch_files_by_time_range–Download files that match extensions within [start, end] hour prefixes.
-
fetch_files_by_time_range_and_basenames–Download files whose basename (final path segment) is in
basenames, -
iter_file_names_by_time_range–Yield blob names under each hourly prefix within [start, end].
-
list_files_by_time_range–List blob names under each hourly prefix within [start, end].
-
stream_files_by_time_range–Stream matching files as (blob_name, bytes-or-parsed) within [start, end].
-
stream_files_by_time_range_and_basenames–Stream files whose basename is in
basenameswithin [start, end].
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
fetch_files_by_time_range
¤
fetch_files_by_time_range(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, *, extensions: Optional[Iterable[str]] = None, parse: bool = False) -> Dict[str, Any]
Download files that match extensions within [start, end] hour prefixes. Returns a dict mapping blob_name -> parsed object (if parse=True and a parser exists), otherwise raw bytes.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
fetch_files_by_time_range_and_basenames
¤
fetch_files_by_time_range_and_basenames(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, basenames: Iterable[str], *, extensions: Optional[Iterable[str]] = None, parse: bool = False) -> Dict[str, Any]
Download files whose basename (final path segment) is in basenames,
optionally filtered by extensions, within [start, end] hour prefixes.
Returns blob_name -> parsed object (if parse=True and a parser exists), otherwise raw bytes.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | |
iter_file_names_by_time_range
¤
iter_file_names_by_time_range(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, *, extensions: Optional[Iterable[str]] = None) -> Iterator[str]
Yield blob names under each hourly prefix within [start, end]. Uses server-side prefix listing and client-side extension filtering.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | |
list_files_by_time_range
¤
list_files_by_time_range(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, *, extensions: Optional[Iterable[str]] = None, limit: Optional[int] = None) -> List[str]
List blob names under each hourly prefix within [start, end].
Parameters:
-
(extensions¤Optional[Iterable[str]], default:None) –Optional set/list of file extensions (e.g., {"json", ".bmp"}). Case-insensitive.
-
(limit¤Optional[int], default:None) –Optional cap on number of files collected.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | |
stream_files_by_time_range
¤
stream_files_by_time_range(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, *, extensions: Optional[Iterable[str]] = None, parse: bool = False) -> Iterator[Tuple[str, Any]]
Stream matching files as (blob_name, bytes-or-parsed) within [start, end].
Maintains up to max_workers concurrent downloads while yielding incrementally.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | |
stream_files_by_time_range_and_basenames
¤
stream_files_by_time_range_and_basenames(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, basenames: Iterable[str], *, extensions: Optional[Iterable[str]] = None, parse: bool = False) -> Iterator[Tuple[str, Any]]
Stream files whose basename is in basenames within [start, end].
Yields (blob_name, bytes-or-parsed) incrementally with bounded concurrency.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
AzureBlobParquetLoader
¤
AzureBlobParquetLoader(container_name: str, *, connection_string: Optional[str] = None, account_url: Optional[str] = None, credential: Optional[object] = None, prefix: str = '', max_workers: int = 8, hour_pattern: str = '{Y}/{m}/{d}/{H}/')
Load parquet files from an Azure Blob Storage container filtered by a list of UUIDs.
Optimized for speed by: - Using server-side prefix filtering when provided - Streaming blob listings and filtering client-side by UUID containment - Downloading and parsing parquet files concurrently
Parameters:
-
(connection_string¤Optional[str], default:None) –Azure Storage connection string.
-
(container_name¤str) –Target container name.
-
(prefix¤str, default:'') –Optional path prefix to narrow listing (e.g. "year/month/").
-
(max_workers¤int, default:8) –Max concurrent downloads/reads.
Methods:
-
from_account_name–Construct a loader using AAD credentials with an account name.
-
list_structure–List folder prefixes (hours) and blob names under the configured
prefix. -
load_all_files–Load all parquet blobs in the container (optionally under
prefix). -
load_by_time_range–Load all parquet blobs under hourly folders within [start, end].
-
load_files_by_time_range_and_uuids–Load parquet blobs for given UUIDs within [start, end] hours.
-
stream_by_time_range–Stream parquet DataFrames under hourly folders within [start, end].
-
stream_files_by_time_range_and_uuids–Stream parquet DataFrames for given UUIDs within [start, end] hours.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
from_account_name
classmethod
¤
from_account_name(account_name: str, container_name: str, *, credential: Optional[object] = None, endpoint_suffix: str = 'blob.core.windows.net', prefix: str = '', max_workers: int = 8) -> AzureBlobParquetLoader
Construct a loader using AAD credentials with an account name.
Parameters:
-
(account_name¤str) –Storage account name.
-
(container_name¤str) –Target container.
-
(credential¤Optional[object], default:None) –Optional Azure credential (DefaultAzureCredential if None).
-
(endpoint_suffix¤str, default:'blob.core.windows.net') –DNS suffix for the blob endpoint (e.g., for sovereign clouds).
-
(prefix¤str, default:'') –Optional listing prefix (e.g., "parquet/").
-
(max_workers¤int, default:8) –Concurrency for downloads.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
list_structure
¤
List folder prefixes (hours) and blob names under the configured prefix.
Parameters:
-
(parquet_only¤bool, default:True) –If True, only include blobs ending with .parquet.
-
(limit¤Optional[int], default:None) –Optional cap on number of files collected for quick inspection.
Returns:
-
Dict[str, List[str]]–A dict with:
-
Dict[str, List[str]]–- folders: Sorted unique hour-level prefixes like 'parquet/YYYY/MM/DD/HH/'
-
Dict[str, List[str]]–- files: Sorted blob names (full paths) matching the filter
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
load_all_files
¤
load_all_files() -> DataFrame
Load all parquet blobs in the container (optionally under prefix).
Returns:
-
DataFrame–A concatenated DataFrame of all parquet blobs. Returns an empty DataFrame
-
DataFrame–if none are found.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
load_by_time_range
¤
Load all parquet blobs under hourly folders within [start, end].
Assumes container structure: prefix/year/month/day/hour/{file}.parquet Listing is constrained per-hour for speed.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
load_files_by_time_range_and_uuids
¤
load_files_by_time_range_and_uuids(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, uuid_list: List[str]) -> DataFrame
Load parquet blobs for given UUIDs within [start, end] hours.
Strategy: 1) Construct direct blob paths assuming pattern prefix/YYYY/MM/DD/HH/{uuid}.parquet (fast path, no listing). 2) For robustness, also list each hour prefix and include any blob whose basename equals one of the requested UUID variants (handles case differences and extra subfolders below the hour level).
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
stream_by_time_range
¤
stream_by_time_range(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp) -> Iterator[Tuple[str, DataFrame]]
Stream parquet DataFrames under hourly folders within [start, end].
Yields (blob_name, DataFrame) one by one to avoid holding everything in memory.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
stream_files_by_time_range_and_uuids
¤
stream_files_by_time_range_and_uuids(start_timestamp: str | Timestamp, end_timestamp: str | Timestamp, uuid_list: List[str]) -> Iterator[Tuple[str, DataFrame]]
Stream parquet DataFrames for given UUIDs within [start, end] hours.
Yields (blob_name, DataFrame) as they arrive. Uses direct names plus per-hour listing fallback.
Source code in src/ts_shape/loader/timeseries/azure_blob_loader.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |