fiftyone.core.session#

Module contents#

Session definitions for interacting with the FiftyOne App.

Copyright 2017-2025, Voxel51, Inc.

Functions:

close_app()

Closes the FiftyOne App, if necessary.

launch_app([dataset,Β view,Β sample_id,Β ...])

Launches the FiftyOne App.

Classes:

Session([dataset,Β view,Β sample_id,Β ...])

Session that maintains a 1-1 shared state with the FiftyOne App.

fiftyone.core.session.close_app() None#

Closes the FiftyOne App, if necessary.

If no App is currently open, this method has no effect.

fiftyone.core.session.launch_app(dataset: Dataset = None, view: DatasetView = None, sample_id: str = None, group_id: str = None, spaces: Space = None, color_scheme: ColorScheme = None, plots: PlotManager = None, port: int = None, address: str = None, remote: bool = False, browser: str = None, height: int = None, auto: bool = True, config: AppConfig = None) Session#

Launches the FiftyOne App.

Note that only one App instance can be opened at a time. If this method is called when another App exists, the existing App will be closed.

Parameters:
Returns:

a Session

class fiftyone.core.session.Session(dataset: Dataset | DatasetView = None, view: DatasetView = None, sample_id: str = None, group_id: str = None, spaces: Space = None, color_scheme: ColorScheme = None, plots: PlotManager = None, port: int = None, address: str = None, remote: bool = False, browser: str = None, height: int = None, auto: bool = True, config: AppConfig = None, view_name: str = None)#

Bases: object

Session that maintains a 1-1 shared state with the FiftyOne App.

Basic Usage

Parameters:

Attributes:

auto

The auto setting for the session.

server_port

The server port for the session.

server_address

The server address for the session, or None if not specified.

remote

Whether the session is remote.

url

The URL of the session.

config

The current fiftyone.core.config.AppConfig.

group_id

The current fiftyone.core.groups.Group ID in the modal, if any.

sample_id

The current fiftyone.core.sample.Sample ID in the modal, if any.

spaces

The layout state for the session.

color_scheme

The color scheme for the session.

dataset

The fiftyone.core.dataset.Dataset connected to the session.

view

The fiftyone.core.view.DatasetView connected to the session, or None if no view is connected.

has_plots

Whether this session has any attached plots.

plots

The fiftyone.core.plots.manager.PlotManager instance that manages plots attached to this session.

selected

A list of sample IDs of the currently selected samples in the App, if any.

selected_labels

A list of labels currently selected in the App.

selected_view

A fiftyone.core.view.DatasetView containing the currently selected content in the App.

Methods:

load_workspace(workspace)

Loads the given saved workspace.

clear_dataset()

Clears the current fiftyone.core.dataset.Dataset from the session, if any.

clear_view()

Clears the current fiftyone.core.view.DatasetView from the session, if any.

refresh()

Refreshes the current App window.

clear_selected()

Clears the currently selected samples, if any.

select_samples([ids,Β tags])

Selects the specified samples in the current view in the App,

select_labels([labels,Β ids,Β instance_ids,Β ...])

Selects the specified labels in the current view in the App.

clear_selected_labels()

Clears the currently selected labels, if any.

tag_selected_samples(tag)

Adds the tag to the currently selected samples, if necessary.

untag_selected_samples(tag)

Removes the tag from the currently selected samples, if necessary.

tag_selected_labels(tag)

Adds the tag to the currently selected labels, if necessary.

untag_selected_labels(tag)

Removes the tag from the currently selected labels, if necessary.

summary()

Returns a string summary of the session.

open()

Opens the App, if necessary.

open_tab()

Opens the App in a new tab of your browser.

show([height])

Opens the App in the output of the current notebook cell.

no_show()

Returns a context manager that temporarily prevents new App instances from being opened in the current notebook cell when methods are run that normally would show new App windows.

wait([wait])

Blocks execution until the App is closed by the user.

close()

Closes the session and terminates the App, if necessary.

freeze()

Screenshots the active App cell, replacing it with a static image.

property auto: bool#

The auto setting for the session.

property server_port: int#

The server port for the session.

property server_address: str#

The server address for the session, or None if not specified.

property remote: bool#

Whether the session is remote.

property url: str#

The URL of the session.

property config: AppConfig#

The current fiftyone.core.config.AppConfig.

For changes to a session’s config to take effect in the App, a call to Session.refresh() or another state-updating action such as session.view = my_view must occur.

Example usage:

import fiftyone as fo

dataset, session = fo.quickstart()

# change the show confidence setting and push the change to the App
session.config.show_confidence = False
session.refresh()
property group_id: str | None#

The current fiftyone.core.groups.Group ID in the modal, if any.

property sample_id: str | None#

The current fiftyone.core.sample.Sample ID in the modal, if any.

property spaces: Space#

The layout state for the session.

load_workspace(workspace: str) None#

Loads the given saved workspace.

Parameters:

workspace – the name of a saved workspace

property color_scheme: ColorScheme#

The color scheme for the session.

property dataset: Dataset | None#

The fiftyone.core.dataset.Dataset connected to the session.

clear_dataset() None#

Clears the current fiftyone.core.dataset.Dataset from the session, if any.

property view: DatasetView | None#

The fiftyone.core.view.DatasetView connected to the session, or None if no view is connected.

clear_view() None#

Clears the current fiftyone.core.view.DatasetView from the session, if any.

property has_plots: bool#

Whether this session has any attached plots.

property plots: PlotManager | None#

The fiftyone.core.plots.manager.PlotManager instance that manages plots attached to this session.

refresh() None#

Refreshes the current App window.

property selected: List[str]#

A list of sample IDs of the currently selected samples in the App, if any.

clear_selected() None#

Clears the currently selected samples, if any.

select_samples(ids: str | Iterable[str] | None = None, tags: str | Iterable[str] | None = None) None#

Selects the specified samples in the current view in the App,

Parameters:
  • ids (None) – an ID or iterable of IDs of samples to select

  • tags (None) – a tag or iterable of tags of samples to select

property selected_labels: List[dict]#

A list of labels currently selected in the App.

Items are dictionaries with the following keys:

  • label_id: the ID of the label

  • sample_id: the ID of the sample containing the label

  • instance_id: the instance ID of the label (optional)

  • field: the field name containing the label

  • frame_number: the frame number containing the label (only applicable to video samples)

select_labels(labels: List[dict] | None = None, ids: str | Iterable[str] | None = None, instance_ids: str | Iterable[str] | None = None, tags: str | Iterable[str] | None = None, fields: str | Iterable[str] | None = None) None#

Selects the specified labels in the current view in the App.

This method uses the same interface as fiftyone.core.collections.SampleCollection.select_labels() to specify the labels to select.

Parameters:
  • labels (None) – a list of dicts specifying the labels to select

  • ids (None) – an ID or iterable of IDs of the labels to select

  • instance_ids (None) – an instance ID or iterable of instance IDs of the labels to select

  • tags (None) – a tag or iterable of tags of labels to select

  • fields (None) – a field or iterable of fields from which to select

clear_selected_labels() None#

Clears the currently selected labels, if any.

tag_selected_samples(tag: str) None#

Adds the tag to the currently selected samples, if necessary.

The currently selected labels are Session.selected.

Parameters:

tag – a tag

untag_selected_samples(tag: str) None#

Removes the tag from the currently selected samples, if necessary.

The currently selected labels are Session.selected.

Parameters:

tag – a tag

tag_selected_labels(tag: str) None#

Adds the tag to the currently selected labels, if necessary.

The currently selected labels are Session.selected_labels.

Parameters:

tag – a tag

untag_selected_labels(tag: str) None#

Removes the tag from the currently selected labels, if necessary.

The currently selected labels are Session.selected_labels.

Parameters:

tag – a tag

property selected_view: DatasetView | None#

A fiftyone.core.view.DatasetView containing the currently selected content in the App.

The selected view is defined as follows:

  • If both samples and labels are selected, the view will contain only the selected_labels from within the selected samples

  • If samples are selected, the view will only contain the selected samples

  • If labels are selected, the view will only contain the selected_labels

  • If no samples or labels are selected, the view will be None

summary() str#

Returns a string summary of the session.

Returns:

a string summary

open() None#

Opens the App, if necessary.

The behavior of this method depends on your context:

  • Notebooks: calls Session.show() to open a new App window in the output of your current cell

  • Other (non-remote): opens the App in a new browser tab

open_tab() None#

Opens the App in a new tab of your browser.

This method can be called from Jupyter notebooks to override the default location of the App.

show(height: int = None) None#

Opens the App in the output of the current notebook cell.

This method has no effect in non-notebook contexts.

Parameters:

height (None) – a height, in pixels, for the App

no_show() SetAttributes#

Returns a context manager that temporarily prevents new App instances from being opened in the current notebook cell when methods are run that normally would show new App windows.

This method has no effect in non-notebook contexts.

Examples:

import fiftyone as fo

dataset = foz.load_zoo_dataset("quickstart")
session = fo.launch_app(dataset)

# (new cell)

# Opens a new App instance
session.view = dataset.take(100)

# (new cell)

# Does not open a new App instance
with session.no_show():
    session.view = dataset.take(100)
Returns:

a context manager

wait(wait: float = 3) None#

Blocks execution until the App is closed by the user.

All connected windows (tabs) must be closed before this method will unblock.

Parameters:

wait (3) – the number of seconds to wait for a new App connection before returning if all connections are lost. If negative, the process will wait forever, regardless of connections

close() None#

Closes the session and terminates the App, if necessary.

freeze() None#

Screenshots the active App cell, replacing it with a static image.

Only applicable to notebook contexts.