Skip to content

Commit

Permalink
Merge branch 'release/v0.23.3' into bug/app-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Jan 16, 2024
2 parents 4821a4e + e8c8e97 commit 1ea8c5b
Show file tree
Hide file tree
Showing 52 changed files with 1,524 additions and 435 deletions.
2 changes: 1 addition & 1 deletion app/packages/looker/src/overlays/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const accumulateOverlays = <State extends BaseState>(
continue;
}

if (label._cls === DYNAMIC_EMBEDDED_DOCUMENT && depth) {
if (depth && label._cls === DYNAMIC_EMBEDDED_DOCUMENT) {
const nestedResult = accumulateOverlays(label, `${field}.`, depth - 1);
classifications.push(...nestedResult.classifications);
overlays.push(...nestedResult.overlays);
Expand Down
8 changes: 3 additions & 5 deletions app/packages/looker/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
BufferRange,
Buffers,
Coordinates,
CustomizeColor,
Dimensions,
DispatchEvent,
} from "./state";
Expand All @@ -23,9 +22,8 @@ import {
NetworkError,
ServerError,
} from "@fiftyone/utilities";
import LookerWorker from "./worker/index.ts?worker&inline";
import { BufferManager } from "./lookers/imavid/buffer-manager";
import { DEFAULT_FRAME_RATE } from "./lookers/imavid/constants";
import LookerWorker from "./worker/index.ts?worker&inline";

/**
* Shallow data-object comparison for equality
Expand Down Expand Up @@ -407,9 +405,9 @@ export const clampScale = (
};

export const mergeUpdates = <State extends BaseState>(
state: Partial<State>,
state: State,
updates: Partial<State>
): Partial<State> => {
): State => {
const merger = (o, n) => {
if (Array.isArray(n)) {
return n;
Expand Down
22 changes: 16 additions & 6 deletions app/packages/looker/src/zoom.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DYNAMIC_EMBEDDED_DOCUMENT } from "@fiftyone/utilities";
import { MIN_PIXELS } from "./constants";
import { POINTS_FROM_FO } from "./overlays";
import { Overlay } from "./overlays/base";
Expand Down Expand Up @@ -96,19 +97,28 @@ export const zoomToContent = <

pan = snapBox(scale, pan, [ww, wh], [iw, ih], !state.config.thumbnail);

return mergeUpdates(state, { scale: scale, pan });
return mergeUpdates(state, { scale: scale, pan } as Partial<State>);
};

export const zoomAspectRatio = (
sample: object,
mediaAspectRatio: number
): number => {
let points = [];
Object.entries(sample).forEach(([_, label]) => {
if (label && label._cls in POINTS_FROM_FO) {
points = [...points, ...POINTS_FROM_FO[label._cls](label)];
}
});

const recurse = (data: object, follow: boolean) => {
Object.entries(data).forEach(([_, label]) => {
if (label && label._cls in POINTS_FROM_FO) {
points = [...points, ...POINTS_FROM_FO[label._cls](label)];
}

if (follow && label._cls === DYNAMIC_EMBEDDED_DOCUMENT)
recurse(label, false);
});
};

recurse(sample, true);

let [_, __, width, height] = getContainingBox(points);

if (width === 0 || height === 0) {
Expand Down
22 changes: 13 additions & 9 deletions app/packages/operators/src/operators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getFetchFunction, ServerError } from "@fiftyone/utilities";
import { getFetchFunction, isNullish, ServerError } from "@fiftyone/utilities";
import { CallbackInterface } from "recoil";
import * as types from "./types";
import { stringifyError } from "./utils";
Expand Down Expand Up @@ -418,15 +418,19 @@ class GeneratedMessage {
}
}

function formatSelectedLabels(selectedLabels = {}) {
function formatSelectedLabels(selectedLabels) {
const labels = [];
for (const labelId of Object.keys(selectedLabels)) {
const label = selectedLabels[labelId];
labels.push({
...label,
label_id: labelId,
sample_id: label.sampleId,
frame_number: label.frameNumber,
if (Array.isArray(selectedLabels) && selectedLabels.length > 0) {
return selectedLabels.map((label) => {
const formattedLabel = {
field: label.field,
label_id: label.labelId,
sample_id: label.sampleId,
};
if (!isNullish(label.frameNumber)) {
formattedLabel.frame_number = label.frameNumber;
}
return formattedLabel;
});
}
return labels;
Expand Down
50 changes: 50 additions & 0 deletions docs/source/plugins/developing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ on their execution context from within
.. code-block:: python
:linenos:
import fiftyone as fo
import fiftyone.core.storage as fos
import fiftyone.core.utils as fou
Expand All @@ -1168,6 +1169,55 @@ on their execution context from within
of their delegated operations from the
:ref:`Runs page <teams-managing-delegated-operations>` of the Teams App!

For your convenience, all builtin methods of the FiftyOne SDK that support
rendering progress bars provide an optional `progress` method that you can use
trigger calls to
:meth:`set_progress() <fiftyone.operators.executor.ExecutionContext.set_progress>`
using the pattern show below:

.. code-block:: python
:linenos:
import fiftyone as fo
def execute(self, ctx):
images_dir = ctx.params["images_dir"]
# Custom logic that controls how progress is reported
def set_progress(pb):
if pb.complete:
ctx.set_progress(progress=1, label="Operation complete")
else:
ctx.set_progress(progress=pb.progress)
# Option 1: report progress every five seconds
progress = fo.report_progress(set_progress, dt=5.0)
# Option 2: report progress at 10 equally-spaced increments
# progress = fo.report_progress(set_progress, n=10)
ctx.dataset.add_images_dir(images_dir, progress=progress)
You can also use the builtin
:class:`ProgressHandler <fiftyone.operators.ProgressHandler>` class to
automatically forward logging messages to
:meth:`set_progress() <fiftyone.operators.executor.ExecutionContext.set_progress>`
as `label` values using the pattern shown below:

.. code-block:: python
:linenos:
import logging
import fiftyone.operators as foo
import fiftyone.zoo as foz
def execute(self, ctx):
name = ctx.params["name"]
# Automatically report all `fiftyone` logging messages
with foo.ProgressHandler(ctx, logger=logging.getLogger("fiftyone")):
foz.load_zoo_dataset(name, persistent=True)
.. _operator-execution:

Operator execution
Expand Down
36 changes: 32 additions & 4 deletions docs/source/teams/cloud_media.rst
Original file line number Diff line number Diff line change
Expand Up @@ -652,16 +652,44 @@ collection being annotated, then you can simply pass `cloud_manifest=True`:
The cloud manifest file must contain all media files in the sample
collection being annotated.

.. _teams-annotating-cloud-media-v7:

Annotating cloud-backed datasets with V7 Darwin
_______________________________________________

When using FiftyOne to :ref:`annotate data with V7 Darwin <v7-integration>`,
you can optionally follow the instructions below to instruct V7 to load media
directly from S3, GCS, or Azure buckets rather than the default behavior of
uploading copies of the media from your local machine.

First, follow
`these instructions <https://docs.v7labs.com/docs/external-storage-configuration>`_
to configure external storage for V7. Then, simply provide the
`external_storage` parameter to
:meth:`annotate() <fiftyone.core.collections.SampleCollection.annotate>` and
specify the sluggified external storage name:

.. code-block:: python
:linenos:
anno_key = "cloud_annotations"
results = dataset.annotate(
anno_key,
label_field="ground_truth",
external_storage="example-darwin-storage-slug",
...
)
.. _teams-annotating-cloud-media-labelbox:

Annotating cloud-backed datasets with Labelbox
______________________________________________

When using FiftyOne to
:ref:`annotate data with Labelbox <labelbox-integration>`,
you can optionally follow the instructions below to instruct Labelbox to load media
directly from S3 rather than the default behavior of uploading copies of the
media.
:ref:`annotate data with Labelbox <labelbox-integration>`, you can optionally
follow the instructions below to instruct Labelbox to load media directly from
S3 rather than the default behavior of uploading copies of the media.

This assumes that you have configured the
`S3 integration for Labelbox <https://docs.labelbox.com/docs/import-aws-s3-data>`_.
Expand Down
1 change: 1 addition & 0 deletions fiftyone/__public__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
disable_progress_bars,
pprint,
pformat,
report_progress,
ProgressBar,
)
from .core.view import DatasetView
Expand Down
Loading

0 comments on commit 1ea8c5b

Please sign in to comment.