Files
albert.collections.files
AlbertSession
AlbertSession(
*,
base_url: str,
token: str | None = None,
auth_manager: AlbertClientCredentials
| AlbertSSOClient
| None = None,
retries: int | None = None,
)
Bases: Session
A session that has a base URL, which is prefixed to all request URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The base URL to prefix to all relative request paths (e.g., "https://app.albertinvent.com"). |
required |
token
|
str | None
|
A static JWT token for authentication. Ignored if |
None
|
auth_manager
|
AlbertClientCredentials | AlbertSSOClient
|
An authentication manager used to dynamically fetch and refresh tokens.
If provided, it overrides |
None
|
retries
|
int
|
The number of automatic retries on failed requests (default is 3). |
None
|
Methods:
| Name | Description |
|---|---|
request |
|
Source code in src/albert/core/session.py
request
Source code in src/albert/core/session.py
BaseCollection
BaseCollection(*, session: AlbertSession)
BaseCollection is the base class for all collection classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert API Session instance. |
required |
Source code in src/albert/collections/base.py
FileCategory
FileCollection
FileCollection(*, session: AlbertSession)
Bases: BaseCollection
FileCollection is a collection class for managing File entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Methods:
| Name | Description |
|---|---|
get_by_name |
Gets a file by name and namespace. |
get_signed_download_url |
Get a signed download URL for a file. |
get_signed_upload_url |
Get a signed upload URL for a file. |
sign_and_upload_file |
Sign and upload a file to Albert. |
Source code in src/albert/collections/files.py
get_by_name
get_by_name(
*,
name: str,
namespace: FileNamespace,
generic: bool = False,
) -> FileInfo
Gets a file by name and namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The Name of the file |
required |
namespace
|
FileNamespace
|
The namespace of the file (e.g. AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
generic
|
bool
|
TODO: description, by default False |
False
|
Returns:
| Type | Description |
|---|---|
FileInfo
|
The file information related to the matching file. |
Source code in src/albert/collections/files.py
get_signed_download_url
get_signed_download_url(
*,
name: str,
namespace: FileNamespace,
version_id: str | None = None,
generic: bool = False,
category: FileCategory | None = None,
) -> str
Get a signed download URL for a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The Name of the file |
required |
namespace
|
FileNamespace
|
The namespace of the file (e.g. AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
version_id
|
str | None
|
The version of the file, by default None |
None
|
category
|
FileCategory | None
|
The file category (E.g., SDS, OTHER), by default None |
None
|
Returns:
| Type | Description |
|---|---|
str
|
S3 signed URL. |
Source code in src/albert/collections/files.py
get_signed_upload_url
get_signed_upload_url(
*,
name: str,
namespace: FileNamespace,
content_type: str,
generic: bool = False,
category: FileCategory | None = None,
) -> str
Get a signed upload URL for a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The Name of the file |
required |
namespace
|
FileNamespace
|
The namespace of the file (e.g. AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
content_type
|
str
|
The content type of the file |
required |
category
|
FileCategory | None
|
The File category (E.g., SDS, OTHER), by default None |
None
|
Returns:
| Type | Description |
|---|---|
str
|
S3 signed URL. |
Source code in src/albert/collections/files.py
sign_and_upload_file
sign_and_upload_file(
data: IO,
name: str,
namespace: FileNamespace,
content_type: str,
generic: bool = False,
category: FileCategory | None = None,
) -> None
Sign and upload a file to Albert.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
IO
|
The file data |
required |
name
|
str
|
The name of the file |
required |
namespace
|
FileNamespace
|
The File Namespace (e.g., AGENT, BREAKTHROUGH, PIPELINE, PUBLIC, RESULT, SDS) |
required |
content_type
|
str
|
The content type of the file |
required |
category
|
FileCategory | None
|
The category of the file (E.g., SDS, OTHER), by default None |
None
|
Source code in src/albert/collections/files.py
FileInfo
pydantic-model
Bases: BaseAlbertModel
Show JSON schema:
{
"$defs": {
"FileNamespace": {
"enum": [
"agent",
"breakthrough",
"pipeline",
"public",
"result",
"sds"
],
"title": "FileNamespace",
"type": "string"
}
},
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"size": {
"title": "Size",
"type": "integer"
},
"etag": {
"title": "Etag",
"type": "string"
},
"namespace": {
"anyOf": [
{
"$ref": "#/$defs/FileNamespace"
},
{
"type": "null"
}
],
"default": null
},
"contentType": {
"title": "Contenttype",
"type": "string"
},
"lastModified": {
"format": "date-time",
"title": "Lastmodified",
"type": "string"
},
"metadata": {
"items": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"title": "Metadata",
"type": "array"
}
},
"required": [
"name",
"size",
"etag",
"contentType",
"lastModified"
],
"title": "FileInfo",
"type": "object"
}
Fields:
-
name(str) -
size(int) -
etag(str) -
namespace(FileNamespace | None) -
content_type(str) -
last_modified(datetime) -
metadata(list[dict[str, str]])
FileNamespace
SignURLPOST
pydantic-model
Bases: BaseAlbertModel
Show JSON schema:
{
"$defs": {
"FileCategory": {
"enum": [
"SDS",
"Other"
],
"title": "FileCategory",
"type": "string"
},
"FileNamespace": {
"enum": [
"agent",
"breakthrough",
"pipeline",
"public",
"result",
"sds"
],
"title": "FileNamespace",
"type": "string"
},
"SignURLPOSTFile": {
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"namespace": {
"$ref": "#/$defs/FileNamespace"
},
"contentType": {
"title": "Contenttype",
"type": "string"
},
"metadata": {
"anyOf": [
{
"items": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Metadata"
},
"category": {
"anyOf": [
{
"$ref": "#/$defs/FileCategory"
},
{
"type": "null"
}
],
"default": null
},
"url": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Url"
}
},
"required": [
"name",
"namespace",
"contentType"
],
"title": "SignURLPOSTFile",
"type": "object"
}
},
"properties": {
"files": {
"items": {
"$ref": "#/$defs/SignURLPOSTFile"
},
"title": "Files",
"type": "array"
}
},
"required": [
"files"
],
"title": "SignURLPOST",
"type": "object"
}
Fields:
SignURLPOSTFile
pydantic-model
Bases: BaseAlbertModel
Show JSON schema:
{
"$defs": {
"FileCategory": {
"enum": [
"SDS",
"Other"
],
"title": "FileCategory",
"type": "string"
},
"FileNamespace": {
"enum": [
"agent",
"breakthrough",
"pipeline",
"public",
"result",
"sds"
],
"title": "FileNamespace",
"type": "string"
}
},
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"namespace": {
"$ref": "#/$defs/FileNamespace"
},
"contentType": {
"title": "Contenttype",
"type": "string"
},
"metadata": {
"anyOf": [
{
"items": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Metadata"
},
"category": {
"anyOf": [
{
"$ref": "#/$defs/FileCategory"
},
{
"type": "null"
}
],
"default": null
},
"url": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Url"
}
},
"required": [
"name",
"namespace",
"contentType"
],
"title": "SignURLPOSTFile",
"type": "object"
}
Fields:
-
name(str) -
namespace(FileNamespace) -
content_type(str) -
metadata(list[dict[str, str]] | None) -
category(FileCategory | None) -
url(str | None)