fsspeckit.core API Reference¶
core
¶
Core filesystem functionality for fsspeckit.
Classes¶
fsspeckit.core.GitLabFileSystem
¶
GitLabFileSystem(
base_url: str = "https://gitlab.com",
project_id: str | int | None = None,
project_name: str | None = None,
ref: str = "main",
token: str | None = None,
api_version: str = "v4",
timeout: float = 30.0,
max_pages: int = 1000,
**kwargs: Any,
)
Bases: AbstractFileSystem
Filesystem interface for GitLab repositories.
Provides read-only access to files in GitLab repositories, including: - Public and private repositories - Self-hosted GitLab instances - Branch/tag/commit selection - Token-based authentication
Attributes:
| Name | Type | Description |
|---|---|---|
protocol |
str
|
Always "gitlab" |
base_url |
str
|
GitLab instance URL |
project_id |
str
|
Project ID |
project_name |
str
|
Project name/path |
ref |
str
|
Git reference (branch, tag, commit) |
token |
str
|
Access token |
api_version |
str
|
API version |
Example
Initialize GitLab filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
GitLab instance URL |
'https://gitlab.com'
|
project_id
|
str | int | None
|
Project ID number |
None
|
project_name
|
str | None
|
Project name/path (alternative to project_id) |
None
|
ref
|
str
|
Git reference (branch, tag, or commit SHA) |
'main'
|
token
|
str | None
|
GitLab personal access token |
None
|
api_version
|
str
|
API version to use |
'v4'
|
timeout
|
float
|
Request timeout in seconds (must be positive, max 3600) |
30.0
|
max_pages
|
int
|
Maximum number of pages to fetch (default 1000, max 10000) |
1000
|
**kwargs
|
Any
|
Additional arguments |
{}
|
Source code in src/fsspeckit/core/filesystem/gitlab.py
Functions¶
fsspeckit.core.GitLabFileSystem.__del__
¶
Destructor to ensure cleanup when object is garbage collected.
fsspeckit.core.GitLabFileSystem.cat_file
¶
Get file content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path |
required |
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
| Type | Description |
|---|---|
bytes
|
File content |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If file not found or other HTTP error |
Source code in src/fsspeckit/core/filesystem/gitlab.py
fsspeckit.core.GitLabFileSystem.close
¶
Close the filesystem and cleanup resources.
This method closes the internal requests session to prevent resource leaks. It is safe to call this method multiple times.
Source code in src/fsspeckit/core/filesystem/gitlab.py
fsspeckit.core.GitLabFileSystem.exists
¶
Check if file exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path |
required |
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True if file exists |
Source code in src/fsspeckit/core/filesystem/gitlab.py
fsspeckit.core.GitLabFileSystem.info
¶
Get file information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path |
required |
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
File information |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If file not found or other HTTP error |
Source code in src/fsspeckit/core/filesystem/gitlab.py
fsspeckit.core.GitLabFileSystem.ls
¶
List files in repository with pagination support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Directory path |
''
|
detail
|
bool
|
Whether to return detailed information |
False
|
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
| Type | Description |
|---|---|
list[Any] | Any
|
List of files |
Source code in src/fsspeckit/core/filesystem/gitlab.py
203 204 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 250 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 | |
fsspeckit.core.MonitoredSimpleCacheFileSystem
¶
MonitoredSimpleCacheFileSystem(
fs: AbstractFileSystem | None = None,
cache_storage: str = "~/.cache/fsspec",
verbose: bool = False,
**kwargs: Any,
)
Bases: SimpleCacheFileSystem
Simple cache filesystem with monitoring and logging.
This filesystem wraps another filesystem and caches files locally. It provides monitoring capabilities and verbose logging of cache operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fs
|
AbstractFileSystem | None
|
Underlying filesystem to cache. If None, creates a local filesystem. |
None
|
cache_storage
|
str
|
Cache storage location(s). Can be string path or list of paths. |
'~/.cache/fsspec'
|
verbose
|
bool
|
Whether to enable verbose logging of cache operations. |
False
|
**kwargs
|
Any
|
Additional arguments passed to SimpleCacheFileSystem. |
{}
|
Example
Initialize monitored cache filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fs
|
AbstractFileSystem | None
|
Underlying filesystem to cache. If None, creates a local filesystem. |
None
|
cache_storage
|
str
|
Cache storage location(s). Can be string path or list of paths. |
'~/.cache/fsspec'
|
verbose
|
bool
|
Whether to enable verbose logging of cache operations. |
False
|
**kwargs
|
Any
|
Additional arguments passed to SimpleCacheFileSystem. |
{}
|
Source code in src/fsspeckit/core/filesystem/cache.py
Functions¶
fsspeckit.core.MonitoredSimpleCacheFileSystem.__getattribute__
¶
Custom attribute access to delegate to underlying filesystem.
This method ensures that attributes not found in this class are looked up in the underlying filesystem.
Source code in src/fsspeckit/core/filesystem/cache.py
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 250 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 | |
fsspeckit.core.MonitoredSimpleCacheFileSystem.open
¶
Open a file from cache or remote filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path |
required |
mode
|
str
|
File mode |
'rb'
|
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
File-like object |
Source code in src/fsspeckit/core/filesystem/cache.py
fsspeckit.core.MonitoredSimpleCacheFileSystem.size
¶
Get size of file in bytes.
Checks cache first, falls back to remote filesystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to file |
required |
Returns:
| Type | Description |
|---|---|
int
|
Size of file in bytes |
Example
Source code in src/fsspeckit/core/filesystem/cache.py
fsspeckit.core.MonitoredSimpleCacheFileSystem.sync_cache
¶
Synchronize cache with remote filesystem.
Downloads all files in remote path to cache if not present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reload
|
bool
|
Whether to force reload all files, ignoring existing cache |
False
|
Example
Source code in src/fsspeckit/core/filesystem/cache.py
Functions¶
fsspeckit.core.get_filesystem
¶
get_filesystem(
protocol_or_path: Union[str, None] = "",
storage_options: Union[BaseStorageOptions, dict]
| None = None,
**kwargs: Any,
) -> AbstractFileSystem
Get filesystem instance (simple version).
This is a simplified version of filesystem() for backward compatibility. See filesystem() for full documentation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocol_or_path
|
Union[str, None]
|
Filesystem protocol or path |
''
|
storage_options
|
Union[BaseStorageOptions, dict] | None
|
Storage configuration |
None
|
**kwargs
|
Any
|
Additional arguments |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
AbstractFileSystem |
AbstractFileSystem
|
Filesystem instance |