Buckets:

rtrm's picture
|
download
raw
16.1 kB
# API Reference
## Run[[trackio.Run]]
#### trackio.Run[[trackio.Run]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/run.py#L20)
finishtrackio.Run.finishhttps://github.com/gradio-app/trackio/blob/vr_323/trackio/run.py#L225[]
Cleanup when run is finished.
## init[[trackio.init]]
#### trackio.init[[trackio.init]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/__init__.py#L69)
Creates a new Trackio project and returns a [Run](/docs/trackio/pr_323/en/api#trackio.Run) object.
**Parameters:**
project (`str`) : The name of the project (can be an existing project to continue tracking or a new project to start tracking from scratch).
name (`str`, *optional*) : The name of the run (if not provided, a default name will be generated).
group (`str`, *optional*) : The name of the group which this run belongs to in order to help organize related runs together. You can toggle the entire group's visibilitiy in the dashboard.
space_id (`str`, *optional*) : If provided, the project will be logged to a Hugging Face Space instead of a local directory. Should be a complete Space name like `"username/reponame"` or `"orgname/reponame"`, or just `"reponame"` in which case the Space will be created in the currently-logged-in Hugging Face user's namespace. If the Space does not exist, it will be created. If the Space already exists, the project will be logged to it.
space_storage ([SpaceStorage](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/space_runtime#huggingface_hub.SpaceStorage), *optional*) : Choice of persistent storage tier.
dataset_id (`str`, *optional*) : If a `space_id` is provided, a persistent Hugging Face Dataset will be created and the metrics will be synced to it every 5 minutes. Specify a Dataset with name like `"username/datasetname"` or `"orgname/datasetname"`, or `"datasetname"` (uses currently-logged-in Hugging Face user's namespace), or `None` (uses the same name as the Space but with the `"_dataset"` suffix). If the Dataset does not exist, it will be created. If the Dataset already exists, the project will be appended to it.
config (`dict`, *optional*) : A dictionary of configuration options. Provided for compatibility with `wandb.init()`.
resume (`str`, *optional*, defaults to `"never"`) : Controls how to handle resuming a run. Can be one of: - `"must"`: Must resume the run with the given name, raises error if run doesn't exist - `"allow"`: Resume the run if it exists, otherwise create a new run - `"never"`: Never resume a run, always create a new one
private (`bool`, *optional*) : Whether to make the Space private. If None (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists.
settings (`Any`, *optional*) : Not used. Provided for compatibility with `wandb.init()`.
embed (`bool`, *optional*, defaults to `True`) : If running inside a jupyter/Colab notebook, whether the dashboard should automatically be embedded in the cell when trackio.init() is called.
**Returns:**
``Run``
A [Run](/docs/trackio/pr_323/en/api#trackio.Run) object that can be used to log metrics and finish the run.
## log[[trackio.log]]
#### trackio.log[[trackio.log]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/__init__.py#L249)
Logs metrics to the current run.
**Parameters:**
metrics (`dict`) : A dictionary of metrics to log.
step (`int`, *optional*) : The step number. If not provided, the step will be incremented automatically.
## finish[[trackio.finish]]
#### trackio.finish[[trackio.finish]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/__init__.py#L269)
Finishes the current run.
## save[[trackio.save]]
#### trackio.save[[trackio.save]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/__init__.py#L323)
Saves files to a project (not linked to a specific run). If Trackio is running locally, the
file(s) will be moved to the project's files directory. If Trackio is running in a Space, the
file(s) will be uploaded to the Space's files directory.
Example:
```python
import trackio
trackio.init(project="my-project")
trackio.save("config.yaml")
trackio.save("models/*.pth")
```
**Parameters:**
glob_str (`str` or `Path`) : The file path or glob pattern to save. Can be a single file or a pattern matching multiple files (e.g., `"*.py"`, `"models/**/*.pth"`).
project (`str`, *optional*) : The name of the project to save files to. If not provided, uses the current project from `trackio.init()`. If no project is initialized, raises an error.
**Returns:**
``str``
The path where the file(s) were saved (project's files directory).
## show[[trackio.show]]
#### trackio.show[[trackio.show]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/__init__.py#L433)
Launches the Trackio dashboard.
**Parameters:**
project (`str`, *optional*) : The name of the project whose runs to show. If not provided, all projects will be shown and the user can select one.
theme (`str` or `ThemeClass`, *optional*) : A Gradio Theme to use for the dashboard instead of the default Gradio theme, can be a built-in theme (e.g. `'soft'`, `'citrus'`), a theme from the Hub (e.g. `"gstaff/xkcd"`), or a custom Theme class. If not provided, the `TRACKIO_THEME` environment variable will be used, or if that is not set, the default Gradio theme will be used.
mcp_server (`bool`, *optional*) : If `True`, the Trackio dashboard will be set up as an MCP server and certain functions will be added as MCP tools. If `None` (default behavior), then the `GRADIO_MCP_SERVER` environment variable will be used to determine if the MCP server should be enabled (which is `"True"` on Hugging Face Spaces).
footer (`bool`, *optional*, defaults to `True`) : Whether to show the Gradio footer. When `False`, the footer will be hidden. This can also be controlled via the `footer` query parameter in the URL.
color_palette (`list[str]`, *optional*) : A list of hex color codes to use for plot lines. If not provided, the `TRACKIO_COLOR_PALETTE` environment variable will be used (comma-separated hex codes), or if that is not set, the default color palette will be used. Example: `['#FF0000', '#00FF00', '#0000FF']`
open_browser (`bool`, *optional*, defaults to `True`) : If `True` and not in a notebook, a new browser tab will be opened with the dashboard. If `False`, the browser will not be opened.
block_thread (`bool`, *optional*) : If `True`, the main thread will be blocked until the dashboard is closed. If `None` (default behavior), then the main thread will not be blocked if the dashboard is launched in a notebook, otherwise the main thread will be blocked.
**Returns:**
``app``
The Gradio app object corresponding to the dashboard launched by Trackio.
`url`: The local URL of the dashboard.
`share_url`: The public share URL of the dashboard.
`full_url`: The full URL of the dashboard including the write token (will use the public share URL if launched publicly, otherwise the local URL).
## import_csv[[trackio.import_csv]]
#### trackio.import_csv[[trackio.import_csv]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/imports.py#L10)
Imports a CSV file into a Trackio project. The CSV file must contain a `"step"`
column, may optionally contain a `"timestamp"` column, and any other columns will be
treated as metrics. It should also include a header row with the column names.
TODO: call init() and return a Run object so that the user can continue to log metrics to it.
**Parameters:**
csv_path (`str` or `Path`) : The str or Path to the CSV file to import.
project (`str`) : The name of the project to import the CSV file into. Must not be an existing project.
name (`str`, *optional*) : The name of the Run to import the CSV file into. If not provided, a default name will be generated.
name (`str`, *optional*) : The name of the run (if not provided, a default name will be generated).
space_id (`str`, *optional*) : If provided, the project will be logged to a Hugging Face Space instead of a local directory. Should be a complete Space name like `"username/reponame"` or `"orgname/reponame"`, or just `"reponame"` in which case the Space will be created in the currently-logged-in Hugging Face user's namespace. If the Space does not exist, it will be created. If the Space already exists, the project will be logged to it.
dataset_id (`str`, *optional*) : If provided, a persistent Hugging Face Dataset will be created and the metrics will be synced to it every 5 minutes. Should be a complete Dataset name like `"username/datasetname"` or `"orgname/datasetname"`, or just `"datasetname"` in which case the Dataset will be created in the currently-logged-in Hugging Face user's namespace. If the Dataset does not exist, it will be created. If the Dataset already exists, the project will be appended to it. If not provided, the metrics will be logged to a local SQLite database, unless a `space_id` is provided, in which case a Dataset will be automatically created with the same name as the Space but with the `"_dataset"` suffix.
private (`bool`, *optional*) : Whether to make the Space private. If None (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists.
## import_tf_events[[trackio.import_tf_events]]
#### trackio.import_tf_events[[trackio.import_tf_events]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/imports.py#L153)
Imports TensorFlow Events files from a directory into a Trackio project. Each
subdirectory in the log directory will be imported as a separate run.
**Parameters:**
log_dir (`str` or `Path`) : The str or Path to the directory containing TensorFlow Events files.
project (`str`) : The name of the project to import the TensorFlow Events files into. Must not be an existing project.
name (`str`, *optional*) : The name prefix for runs (if not provided, will use directory names). Each subdirectory will create a separate run.
space_id (`str`, *optional*) : If provided, the project will be logged to a Hugging Face Space instead of a local directory. Should be a complete Space name like `"username/reponame"` or `"orgname/reponame"`, or just `"reponame"` in which case the Space will be created in the currently-logged-in Hugging Face user's namespace. If the Space does not exist, it will be created. If the Space already exists, the project will be logged to it.
dataset_id (`str`, *optional*) : If provided, a persistent Hugging Face Dataset will be created and the metrics will be synced to it every 5 minutes. Should be a complete Dataset name like `"username/datasetname"` or `"orgname/datasetname"`, or just `"datasetname"` in which case the Dataset will be created in the currently-logged-in Hugging Face user's namespace. If the Dataset does not exist, it will be created. If the Dataset already exists, the project will be appended to it. If not provided, the metrics will be logged to a local SQLite database, unless a `space_id` is provided, in which case a Dataset will be automatically created with the same name as the Space but with the `"_dataset"` suffix.
private (`bool`, *optional*) : Whether to make the Space private. If None (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists.
## Table[[trackio.Table]]
#### trackio.Table[[trackio.Table]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/table.py#L14)
Initializes a Table object. Tables can be used to log tabular data including images, numbers, and text.
to_display_formattrackio.Table.to_display_formathttps://github.com/gradio-app/trackio/blob/vr_323/trackio/table.py#L97[{"name": "table_data", "val": ": list"}]- **table_data** -- List of dictionaries representing table rows (from stored _value)0Table data with images converted to markdown syntax and long text truncated.
Convert stored table data to display format for UI rendering. Note
that this does not use the self.data attribute, but instead uses the
table_data parameter, which is is what the UI receives.
**Parameters:**
columns (`list[str]`, *optional*) : Names of the columns in the table. Optional if `data` is provided. Not expected if `dataframe` is provided. Currently ignored.
data (`list[list[Any]]`, *optional*) : 2D row-oriented array of values. Each value can be: a number, a string (treated as Markdown and truncated if too long), or a `Trackio.Image` or list of `Trackio.Image` objects.
dataframe (`pandas.`DataFrame``, *optional*) : DataFrame object used to create the table. When set, `data` and `columns` arguments are ignored.
rows (`list[list[any]]`, *optional*) : Currently ignored.
optional (`bool` or `list[bool]`, *optional*, defaults to `True`) : Currently ignored.
allow_mixed_types (`bool`, *optional*, defaults to `False`) : Currently ignored.
log_mode : (`Literal["IMMUTABLE", "MUTABLE", "INCREMENTAL"]` or `None`, *optional*, defaults to `"IMMUTABLE"`): Currently ignored.
**Returns:**
Table data with images converted to markdown syntax and long text truncated.
## Image[[trackio.TrackioImage]]
#### trackio.TrackioImage[[trackio.TrackioImage]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/media/image.py#L17)
Initializes an Image object.
Example:
```python
import trackio
import numpy as np
from PIL import Image
# Create an image from numpy array
image_data = np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8)
image = trackio.Image(image_data, caption="Random image")
trackio.log({"my_image": image})
# Create an image from PIL Image
pil_image = Image.new('RGB', (100, 100), color='red')
image = trackio.Image(pil_image, caption="Red square")
trackio.log({"red_image": image})
# Create an image from file path
image = trackio.Image("path/to/image.jpg", caption="Photo from file")
trackio.log({"file_image": image})
```
**Parameters:**
value (`str`, `Path`, `numpy.ndarray`, or `PIL.Image`, *optional*) : A path to an image, a PIL Image, or a numpy array of shape (height, width, channels). If numpy array, should be of type `np.uint8` with RGB values in the range `[0, 255]`.
caption (`str`, *optional*) : A string caption for the image.
## Video[[trackio.TrackioVideo]]
#### trackio.TrackioVideo[[trackio.TrackioVideo]]
[Source](https://github.com/gradio-app/trackio/blob/vr_323/trackio/media/video.py#L22)
Initializes a Video object.
Example:
```python
import trackio
import numpy as np
# Create a simple video from numpy array
frames = np.random.randint(0, 255, (10, 3, 64, 64), dtype=np.uint8)
video = trackio.Video(frames, caption="Random video", fps=30)
# Create a batch of videos
batch_frames = np.random.randint(0, 255, (3, 10, 3, 64, 64), dtype=np.uint8)
batch_video = trackio.Video(batch_frames, caption="Batch of videos", fps=15)
# Create video from file path
video = trackio.Video("path/to/video.mp4", caption="Video from file")
```
write_videotrackio.TrackioVideo.write_videohttps://github.com/gradio-app/trackio/blob/vr_323/trackio/media/video.py#L98[{"name": "file_path", "val": ": str | pathlib.Path"}, {"name": "video", "val": ": ndarray"}, {"name": "fps", "val": ": float"}, {"name": "codec", "val": ": typing.Literal['h264', 'vp9', 'gif']"}]
RGB uint8 only, shape (F, H, W, 3).
**Parameters:**
value (`str`, `Path`, or `numpy.ndarray`, *optional*) : A path to a video file, or a numpy array. If numpy array, should be of type `np.uint8` with RGB values in the range `[0, 255]`. It is expected to have shape of either (frames, channels, height, width) or (batch, frames, channels, height, width). For the latter, the videos will be tiled into a grid.
caption (`str`, *optional*) : A string caption for the video.
fps (`int`, *optional*) : Frames per second for the video. Only used when value is an ndarray. Default is `24`.
format (`Literal["gif", "mp4", "webm"]`, *optional*) : Video format ("gif", "mp4", or "webm"). Only used when value is an ndarray. Default is "gif".

Xet Storage Details

Size:
16.1 kB
·
Xet hash:
153ebb17468ef7b19bf3761085ef2d9c4415d9b1219090b170de0c2daa8e717b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.