-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sdk/python: Refactor module structure
Signed-off-by: Aaron Wilson <[email protected]>
- Loading branch information
Showing
44 changed files
with
242 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
""" | ||
Import client-accessible components here to provide consistent imports via `from aistore.sdk import *` | ||
Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved. | ||
""" | ||
|
||
# Clients | ||
from aistore.sdk.client import Client | ||
from aistore.sdk.list_object_flag import ListObjectFlag | ||
from aistore.sdk.bucket import Bucket | ||
from aistore.sdk.namespace import Namespace | ||
from aistore.sdk.authn.authn_client import AuthNClient | ||
|
||
# Core components | ||
from aistore.sdk.cluster import Cluster | ||
from aistore.sdk.namespace import Namespace | ||
from aistore.sdk.ais_source import AISSource | ||
from aistore.sdk.bucket import Bucket | ||
from aistore.sdk.obj.object import Object | ||
from aistore.sdk.job import Job | ||
from aistore.sdk.etl.etl import Etl | ||
|
||
# Config objects, types and dataclasses | ||
from aistore.sdk.archive_config import ArchiveConfig | ||
from aistore.sdk.blob_download_config import BlobDownloadConfig | ||
from aistore.sdk.dataset.data_shard import DataShard | ||
from aistore.sdk.list_object_flag import ListObjectFlag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
||
|
||
class ArchiveMode(Enum): | ||
""" | ||
Archive mode for getting files/objects from an archive in a bucket | ||
See `MatchMode` enum in the cmn/archive/read.go | ||
""" | ||
|
||
REGEXP = "regexp" | ||
PREFIX = "prefix" | ||
SUFFIX = "suffix" | ||
SUBSTR = "substr" | ||
WDSKEY = "wdskey" | ||
|
||
|
||
@dataclass | ||
class ArchiveConfig: | ||
""" | ||
Configuration for extracting files from an archive | ||
Attributes: | ||
archpath (str, optional): If the object is an archive, use `archpath` to extract a single file | ||
from the archive | ||
regex (str, optional): A prefix, suffix, WebDataset key, or general-purpose regular expression | ||
used to match filenames within the archive and select possibly multiple files | ||
mode (ArchiveMode, optional): Specifies the mode of archive extraction when using `regex` | ||
Example: | ||
# Extract a single file from an archive | ||
single_file_settings = ArchiveConfig( | ||
archpath="path/to/your/file.txt" | ||
) | ||
# Extract multiple files from an archive | ||
multi_file_settings = ArchiveConfig( | ||
regex = "log", # Retrieve all log files from the archive | ||
mode=ArchiveMode.SUFFIX, | ||
) | ||
""" | ||
|
||
archpath: str = "" | ||
regex: str = "" | ||
mode: ArchiveMode = None | ||
|
||
def __post_init__(self): | ||
if self.mode and not self.regex: | ||
raise ValueError("Archive mode requires archive regex") | ||
|
||
if self.regex and not self.mode: | ||
raise ValueError("Archive regex requires archive mode") | ||
|
||
if self.regex and self.archpath: | ||
raise ValueError("Cannot use both Archive regex and Archive path") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class BlobDownloadConfig: | ||
""" | ||
Configuration for downloading objects using a blob downloader | ||
Attributes: | ||
chunk_size (str, optional): Chunk size for the blob downloader. It can be specified in IEC | ||
or SI units, or as raw bytes (e.g., "4mb", "1MiB", "1048576", "128k") | ||
num_workers (str, optional): Number of concurrent workers for the blob downloader | ||
Example: | ||
blob_settings = BlobDownloadConfig( | ||
chunk_size="1MiB", # 1 MiB per chunk | ||
num_workers="5" # 5 concurrent download workers | ||
) | ||
""" | ||
|
||
chunk_size: str = None | ||
num_workers: str = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.