Skip to content

Commit

Permalink
chore: Rename API. #1601
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Aug 10, 2023
1 parent 8a9f263 commit bd80a0d
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion py/examples/audio_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def serve(q: Q):
ui.audio_annotator(
name='annotator',
title='Drag to annotate',
src=q.app.uploaded_mp3,
path=q.app.uploaded_mp3,
tags=[
ui.audio_annotator_tag(name='f', label='Flute', color='$blue'),
ui.audio_annotator_tag(name='d', label='Drum', color='$brown'),
Expand Down
22 changes: 11 additions & 11 deletions py/h2o_lightwave/h2o_lightwave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6736,7 +6736,7 @@ def __init__(
self.allowed_shapes = allowed_shapes
"""List of allowed shapes. Available values are 'rect' and 'polygon'. If not set, all shapes are available by default."""
self.events = events
"""The events to capture on this image annotator. One of `click` or `tool_change`."""
"""The events to capture on this image annotator. One of `click` | `tool_change`."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
Expand Down Expand Up @@ -6911,23 +6911,23 @@ def __init__(
self,
name: str,
title: str,
src: str,
path: str,
tags: List[AudioAnnotatorTag],
items: Optional[List[AudioAnnotatorItem]] = None,
trigger: Optional[bool] = None,
):
_guard_scalar('AudioAnnotator.name', name, (str,), True, False, False)
_guard_scalar('AudioAnnotator.title', title, (str,), False, False, False)
_guard_scalar('AudioAnnotator.src', src, (str,), False, False, False)
_guard_scalar('AudioAnnotator.path', path, (str,), False, False, False)
_guard_vector('AudioAnnotator.tags', tags, (AudioAnnotatorTag,), False, False, False)
_guard_vector('AudioAnnotator.items', items, (AudioAnnotatorItem,), False, True, False)
_guard_scalar('AudioAnnotator.trigger', trigger, (bool,), False, True, False)
self.name = name
"""An identifying name for this component."""
self.title = title
"""The audio annotator's title."""
self.src = src
"""The source of the audio. We advise using mp3 or wav formats to achieve the best cross-browser experience. See https://caniuse.com/?search=audio%20format for other formats."""
self.path = path
"""The path to the audio file. Use mp3 or wav formats to achieve the best cross-browser support. See https://caniuse.com/?search=audio%20format for other formats."""
self.tags = tags
"""The master list of tags that can be used for annotations."""
self.items = items
Expand All @@ -6939,14 +6939,14 @@ def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
_guard_scalar('AudioAnnotator.name', self.name, (str,), True, False, False)
_guard_scalar('AudioAnnotator.title', self.title, (str,), False, False, False)
_guard_scalar('AudioAnnotator.src', self.src, (str,), False, False, False)
_guard_scalar('AudioAnnotator.path', self.path, (str,), False, False, False)
_guard_vector('AudioAnnotator.tags', self.tags, (AudioAnnotatorTag,), False, False, False)
_guard_vector('AudioAnnotator.items', self.items, (AudioAnnotatorItem,), False, True, False)
_guard_scalar('AudioAnnotator.trigger', self.trigger, (bool,), False, True, False)
return _dump(
name=self.name,
title=self.title,
src=self.src,
path=self.path,
tags=[__e.dump() for __e in self.tags],
items=None if self.items is None else [__e.dump() for __e in self.items],
trigger=self.trigger,
Expand All @@ -6959,8 +6959,8 @@ def load(__d: Dict) -> 'AudioAnnotator':
_guard_scalar('AudioAnnotator.name', __d_name, (str,), True, False, False)
__d_title: Any = __d.get('title')
_guard_scalar('AudioAnnotator.title', __d_title, (str,), False, False, False)
__d_src: Any = __d.get('src')
_guard_scalar('AudioAnnotator.src', __d_src, (str,), False, False, False)
__d_path: Any = __d.get('path')
_guard_scalar('AudioAnnotator.path', __d_path, (str,), False, False, False)
__d_tags: Any = __d.get('tags')
_guard_vector('AudioAnnotator.tags', __d_tags, (dict,), False, False, False)
__d_items: Any = __d.get('items')
Expand All @@ -6969,14 +6969,14 @@ def load(__d: Dict) -> 'AudioAnnotator':
_guard_scalar('AudioAnnotator.trigger', __d_trigger, (bool,), False, True, False)
name: str = __d_name
title: str = __d_title
src: str = __d_src
path: str = __d_path
tags: List[AudioAnnotatorTag] = [AudioAnnotatorTag.load(__e) for __e in __d_tags]
items: Optional[List[AudioAnnotatorItem]] = None if __d_items is None else [AudioAnnotatorItem.load(__e) for __e in __d_items]
trigger: Optional[bool] = __d_trigger
return AudioAnnotator(
name,
title,
src,
path,
tags,
items,
trigger,
Expand Down
8 changes: 4 additions & 4 deletions py/h2o_lightwave/h2o_lightwave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,7 +2497,7 @@ def image_annotator(
trigger: True if the form should be submitted as soon as an annotation is drawn.
image_height: The card’s image height. The actual image size is used by default.
allowed_shapes: List of allowed shapes. Available values are 'rect' and 'polygon'. If not set, all shapes are available by default.
events: The events to capture on this image annotator. One of `click` or `tool_change`.
events: The events to capture on this image annotator. One of `click` | `tool_change`.
Returns:
A `h2o_wave.types.ImageAnnotator` instance.
"""
Expand Down Expand Up @@ -2559,7 +2559,7 @@ def audio_annotator_item(
def audio_annotator(
name: str,
title: str,
src: str,
path: str,
tags: List[AudioAnnotatorTag],
items: Optional[List[AudioAnnotatorItem]] = None,
trigger: Optional[bool] = None,
Expand All @@ -2571,7 +2571,7 @@ def audio_annotator(
Args:
name: An identifying name for this component.
title: The audio annotator's title.
src: The source of the audio. We advise using mp3 or wav formats to achieve the best cross-browser experience. See https://caniuse.com/?search=audio%20format for other formats.
path: The path to the audio file. Use mp3 or wav formats to achieve the best cross-browser support. See https://caniuse.com/?search=audio%20format for other formats.
tags: The master list of tags that can be used for annotations.
items: Annotations to display on the image, if any.
trigger: True if the form should be submitted as soon as an annotation is made.
Expand All @@ -2581,7 +2581,7 @@ def audio_annotator(
return Component(audio_annotator=AudioAnnotator(
name,
title,
src,
path,
tags,
items,
trigger,
Expand Down
22 changes: 11 additions & 11 deletions py/h2o_wave/h2o_wave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6736,7 +6736,7 @@ def __init__(
self.allowed_shapes = allowed_shapes
"""List of allowed shapes. Available values are 'rect' and 'polygon'. If not set, all shapes are available by default."""
self.events = events
"""The events to capture on this image annotator. One of `click` or `tool_change`."""
"""The events to capture on this image annotator. One of `click` | `tool_change`."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
Expand Down Expand Up @@ -6911,23 +6911,23 @@ def __init__(
self,
name: str,
title: str,
src: str,
path: str,
tags: List[AudioAnnotatorTag],
items: Optional[List[AudioAnnotatorItem]] = None,
trigger: Optional[bool] = None,
):
_guard_scalar('AudioAnnotator.name', name, (str,), True, False, False)
_guard_scalar('AudioAnnotator.title', title, (str,), False, False, False)
_guard_scalar('AudioAnnotator.src', src, (str,), False, False, False)
_guard_scalar('AudioAnnotator.path', path, (str,), False, False, False)
_guard_vector('AudioAnnotator.tags', tags, (AudioAnnotatorTag,), False, False, False)
_guard_vector('AudioAnnotator.items', items, (AudioAnnotatorItem,), False, True, False)
_guard_scalar('AudioAnnotator.trigger', trigger, (bool,), False, True, False)
self.name = name
"""An identifying name for this component."""
self.title = title
"""The audio annotator's title."""
self.src = src
"""The source of the audio. We advise using mp3 or wav formats to achieve the best cross-browser experience. See https://caniuse.com/?search=audio%20format for other formats."""
self.path = path
"""The path to the audio file. Use mp3 or wav formats to achieve the best cross-browser support. See https://caniuse.com/?search=audio%20format for other formats."""
self.tags = tags
"""The master list of tags that can be used for annotations."""
self.items = items
Expand All @@ -6939,14 +6939,14 @@ def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
_guard_scalar('AudioAnnotator.name', self.name, (str,), True, False, False)
_guard_scalar('AudioAnnotator.title', self.title, (str,), False, False, False)
_guard_scalar('AudioAnnotator.src', self.src, (str,), False, False, False)
_guard_scalar('AudioAnnotator.path', self.path, (str,), False, False, False)
_guard_vector('AudioAnnotator.tags', self.tags, (AudioAnnotatorTag,), False, False, False)
_guard_vector('AudioAnnotator.items', self.items, (AudioAnnotatorItem,), False, True, False)
_guard_scalar('AudioAnnotator.trigger', self.trigger, (bool,), False, True, False)
return _dump(
name=self.name,
title=self.title,
src=self.src,
path=self.path,
tags=[__e.dump() for __e in self.tags],
items=None if self.items is None else [__e.dump() for __e in self.items],
trigger=self.trigger,
Expand All @@ -6959,8 +6959,8 @@ def load(__d: Dict) -> 'AudioAnnotator':
_guard_scalar('AudioAnnotator.name', __d_name, (str,), True, False, False)
__d_title: Any = __d.get('title')
_guard_scalar('AudioAnnotator.title', __d_title, (str,), False, False, False)
__d_src: Any = __d.get('src')
_guard_scalar('AudioAnnotator.src', __d_src, (str,), False, False, False)
__d_path: Any = __d.get('path')
_guard_scalar('AudioAnnotator.path', __d_path, (str,), False, False, False)
__d_tags: Any = __d.get('tags')
_guard_vector('AudioAnnotator.tags', __d_tags, (dict,), False, False, False)
__d_items: Any = __d.get('items')
Expand All @@ -6969,14 +6969,14 @@ def load(__d: Dict) -> 'AudioAnnotator':
_guard_scalar('AudioAnnotator.trigger', __d_trigger, (bool,), False, True, False)
name: str = __d_name
title: str = __d_title
src: str = __d_src
path: str = __d_path
tags: List[AudioAnnotatorTag] = [AudioAnnotatorTag.load(__e) for __e in __d_tags]
items: Optional[List[AudioAnnotatorItem]] = None if __d_items is None else [AudioAnnotatorItem.load(__e) for __e in __d_items]
trigger: Optional[bool] = __d_trigger
return AudioAnnotator(
name,
title,
src,
path,
tags,
items,
trigger,
Expand Down
8 changes: 4 additions & 4 deletions py/h2o_wave/h2o_wave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,7 +2497,7 @@ def image_annotator(
trigger: True if the form should be submitted as soon as an annotation is drawn.
image_height: The card’s image height. The actual image size is used by default.
allowed_shapes: List of allowed shapes. Available values are 'rect' and 'polygon'. If not set, all shapes are available by default.
events: The events to capture on this image annotator. One of `click` or `tool_change`.
events: The events to capture on this image annotator. One of `click` | `tool_change`.
Returns:
A `h2o_wave.types.ImageAnnotator` instance.
"""
Expand Down Expand Up @@ -2559,7 +2559,7 @@ def audio_annotator_item(
def audio_annotator(
name: str,
title: str,
src: str,
path: str,
tags: List[AudioAnnotatorTag],
items: Optional[List[AudioAnnotatorItem]] = None,
trigger: Optional[bool] = None,
Expand All @@ -2571,7 +2571,7 @@ def audio_annotator(
Args:
name: An identifying name for this component.
title: The audio annotator's title.
src: The source of the audio. We advise using mp3 or wav formats to achieve the best cross-browser experience. See https://caniuse.com/?search=audio%20format for other formats.
path: The path to the audio file. Use mp3 or wav formats to achieve the best cross-browser support. See https://caniuse.com/?search=audio%20format for other formats.
tags: The master list of tags that can be used for annotations.
items: Annotations to display on the image, if any.
trigger: True if the form should be submitted as soon as an annotation is made.
Expand All @@ -2581,7 +2581,7 @@ def audio_annotator(
return Component(audio_annotator=AudioAnnotator(
name,
title,
src,
path,
tags,
items,
trigger,
Expand Down
10 changes: 5 additions & 5 deletions r/R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -2894,7 +2894,7 @@ ui_image_annotator_item <- function(
#' @param trigger True if the form should be submitted as soon as an annotation is drawn.
#' @param image_height The card’s image height. The actual image size is used by default.
#' @param allowed_shapes List of allowed shapes. Available values are 'rect' and 'polygon'. If not set, all shapes are available by default.
#' @param events The events to capture on this image annotator. One of `click` or `tool_change`.
#' @param events The events to capture on this image annotator. One of `click` | `tool_change`.
#' @return A ImageAnnotator instance.
#' @export
ui_image_annotator <- function(
Expand Down Expand Up @@ -2980,7 +2980,7 @@ ui_audio_annotator_item <- function(
#'
#' @param name An identifying name for this component.
#' @param title The audio annotator's title.
#' @param src The source of the audio. We advise using mp3 or wav formats to achieve the best cross-browser experience. See https://caniuse.com/?search=audio%20format for other formats.
#' @param path The path to the audio file. Use mp3 or wav formats to achieve the best cross-browser support. See https://caniuse.com/?search=audio%20format for other formats.
#' @param tags The master list of tags that can be used for annotations.
#' @param items Annotations to display on the image, if any.
#' @param trigger True if the form should be submitted as soon as an annotation is made.
Expand All @@ -2989,20 +2989,20 @@ ui_audio_annotator_item <- function(
ui_audio_annotator <- function(
name,
title,
src,
path,
tags,
items = NULL,
trigger = NULL) {
.guard_scalar("name", "character", name)
.guard_scalar("title", "character", title)
.guard_scalar("src", "character", src)
.guard_scalar("path", "character", path)
.guard_vector("tags", "WaveAudioAnnotatorTag", tags)
.guard_vector("items", "WaveAudioAnnotatorItem", items)
.guard_scalar("trigger", "logical", trigger)
.o <- list(audio_annotator=list(
name=name,
title=title,
src=src,
path=path,
tags=tags,
items=items,
trigger=trigger))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<option name="Python" value="true"/>
</context>
</template>
<template name="w_audio_annotator" value="ui.audio_annotator(name='$name$',title='$title$',src='$src$',tags=[&#10; $tags$ &#10;]),$END$" description="Create a minimal Wave AudioAnnotator." toReformat="true" toShortenFQNames="true">
<template name="w_audio_annotator" value="ui.audio_annotator(name='$name$',title='$title$',path='$path$',tags=[&#10; $tags$ &#10;]),$END$" description="Create a minimal Wave AudioAnnotator." toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="title" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="src" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="path" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="tags" expression="" defaultValue="" alwaysStopAt="true"/>
<context>
<option name="Python" value="true"/>
Expand Down Expand Up @@ -1025,10 +1025,10 @@
<option name="Python" value="true"/>
</context>
</template>
<template name="w_full_audio_annotator" value="ui.audio_annotator(name='$name$',title='$title$',src='$src$',trigger=$trigger$,tags=[&#10; $tags$ &#10;],items=[&#10; $items$ &#10;]),$END$" description="Create Wave AudioAnnotator with full attributes." toReformat="true" toShortenFQNames="true">
<template name="w_full_audio_annotator" value="ui.audio_annotator(name='$name$',title='$title$',path='$path$',trigger=$trigger$,tags=[&#10; $tags$ &#10;],items=[&#10; $items$ &#10;]),$END$" description="Create Wave AudioAnnotator with full attributes." toReformat="true" toShortenFQNames="true">
<variable name="name" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="title" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="src" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="path" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="trigger" expression="" defaultValue="&quot;False&quot;" alwaysStopAt="true"/>
<variable name="tags" expression="" defaultValue="" alwaysStopAt="true"/>
<variable name="items" expression="" defaultValue="" alwaysStopAt="true"/>
Expand Down
4 changes: 2 additions & 2 deletions tools/vscode-extension/component-snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Wave AudioAnnotator": {
"prefix": "w_audio_annotator",
"body": [
"ui.audio_annotator(name='$1', title='$2', src='$3', tags=[\n\t\t$4\t\t\n]),$0"
"ui.audio_annotator(name='$1', title='$2', path='$3', tags=[\n\t\t$4\t\t\n]),$0"
],
"description": "Create a minimal Wave AudioAnnotator."
},
Expand Down Expand Up @@ -989,7 +989,7 @@
"Wave Full AudioAnnotator": {
"prefix": "w_full_audio_annotator",
"body": [
"ui.audio_annotator(name='$1', title='$2', src='$3', trigger=${4:False}, tags=[\n\t\t$5\t\t\n], items=[\n\t\t$6\t\t\n]),$0"
"ui.audio_annotator(name='$1', title='$2', path='$3', trigger=${4:False}, tags=[\n\t\t$5\t\t\n], items=[\n\t\t$6\t\t\n]),$0"
],
"description": "Create a full Wave AudioAnnotator."
},
Expand Down
2 changes: 1 addition & 1 deletion ui/src/audio_annotator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const
model: AudioAnnotator = {
name,
title: name,
src: '',
path: '',
tags: [
{ name: 'tag1', label: 'Tag 1', color: 'red' },
{ name: 'tag2', label: 'Tag 2', color: 'blue' },
Expand Down
6 changes: 3 additions & 3 deletions ui/src/audio_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export interface AudioAnnotator {
name: Id,
/** The audio annotator's title. */
title: S
/** The source of the audio. We advise using mp3 or wav formats to achieve the best cross-browser experience. See https://caniuse.com/?search=audio%20format for other formats. */
src: S
/** The path to the audio file. Use mp3 or wav formats to achieve the best cross-browser support. See https://caniuse.com/?search=audio%20format for other formats. */
path: S
/** The master list of tags that can be used for annotations. */
tags: AudioAnnotatorTag[]
/** Annotations to display on the image, if any. */
Expand Down Expand Up @@ -114,7 +114,7 @@ export const XAudioAnnotator = ({ model }: { model: AudioAnnotator }) => {
let arrBuffer: ArrayBuffer
try {
// The data audio needs to be fetched and processed manually to generate a waveform later.
const res = await fetch(model.src)
const res = await fetch(model.path)
arrBuffer = await res.arrayBuffer()
} catch (e) {
setErrMsg('Could not download audio file.')
Expand Down
2 changes: 1 addition & 1 deletion ui/src/image_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface ImageAnnotator {
image_height?: S
/** List of allowed shapes. Available values are 'rect' and 'polygon'. If not set, all shapes are available by default. */
allowed_shapes?: S[]
/** The events to capture on this image annotator. One of `click` or `tool_change`. */
/** The events to capture on this image annotator. One of `click` | `tool_change`. */
events?: S[]
}

Expand Down

0 comments on commit bd80a0d

Please sign in to comment.