Data Files¶
Generic data-file operations are accessed via
Client.data.
Upload a data file:
from pathlib import Path
from flowbio.v2 import Client, TokenCredentials
client = Client()
client.log_in(TokenCredentials(token))
data = client.data.upload_data(Path("counts.tsv"))
print(data.id)
Uploading Data Files¶
Use upload_data() to upload a generic
data file. The file is uploaded in chunks and the created data file is
returned:
from pathlib import Path
data = client.data.upload_data(Path("counts.tsv"))
print(f"Data ID: {data.id}")
Store the file under a different name than the local path with the
filename override (the name must contain no spaces):
data = client.data.upload_data(
Path("counts.tsv"),
filename="experiment_42_counts.tsv",
)
Tag the file with a DataType identifier, or upload an archive for the
server to unpack:
data = client.data.upload_data(Path("reads.bam"), data_type="bam")
archive = client.data.upload_data(Path("results.zip"), is_directory=True)
See upload_data() for the full list of
parameters.
API Reference¶
- class flowbio.v2.data.DataResource(uploader)¶
Provides access to generic data-file API endpoints.
Accessed via
Client.data:client = Client() data = client.data.upload_data(Path("counts.tsv"))
- upload_data(path, filename=None, data_type=None, is_directory=False)¶
Upload a generic data file to the Flow platform.
Uploads the file in chunks (chunk size and progress display are controlled via
flowbio.v2.ClientConfig) and returns the created data file.Requires authentication.
Example:
from pathlib import Path data = client.data.upload_data(Path("counts.tsv")) print(f"Data ID: {data.id}")
- Parameters:
path (
Path) – The local file to upload.filename (
str|None) – Optional override for the name the file is stored under on Flow. Defaults topath.name. Useful when reading from a local path but storing under a different name. Must contain no spaces — the server rejects spaces with aBadRequestError.data_type (
str|None) – OptionalDataTypeidentifier. Validated server-side only; an invalid value raises aBadRequestError.is_directory (
bool) – WhenTrue, the server treats the upload as an archive and unpacks it.pathmust then point at a.zip/.tar/.tar.gz.
- Return type:
- Returns:
The created
Data.- Raises:
BadRequestError – If the filename contains spaces or
data_typeis invalid.AuthenticationError – If the request is unauthenticated.