-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
768 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
if [ -n "${GITHUB_ACTIONS-}" ]; then | ||
set -x | ||
fi | ||
|
||
# Check pipefail support in a subshell, ignore if unsupported | ||
# shellcheck disable=SC3040 | ||
(set -o pipefail 2> /dev/null) && set -o pipefail | ||
|
||
help() { | ||
cat <<'EOF' | ||
Install a binary release of a dora hosted on GitHub | ||
USAGE: | ||
install [options] | ||
FLAGS: | ||
-h, --help Display this message | ||
-f, --force Force overwriting an existing binary | ||
OPTIONS: | ||
--tag TAG Tag (version) of the crate to install, defaults to latest release | ||
--to LOCATION Where to install the binary [default: ~/bin] | ||
--target TARGET | ||
EOF | ||
} | ||
|
||
crate=dora | ||
url=https://github.com/dora-rs/dora | ||
releases=$url/releases | ||
|
||
say() { | ||
echo "install: $*" >&2 | ||
} | ||
|
||
err() { | ||
if [ -n "${td-}" ]; then | ||
rm -rf "$td" | ||
fi | ||
|
||
say "error: $*" | ||
exit 1 | ||
} | ||
|
||
need() { | ||
if ! command -v "$1" > /dev/null 2>&1; then | ||
err "need $1 (command not found)" | ||
fi | ||
} | ||
|
||
force=false | ||
while test $# -gt 0; do | ||
case $1 in | ||
--force | -f) | ||
force=true | ||
;; | ||
--help | -h) | ||
help | ||
exit 0 | ||
;; | ||
--tag) | ||
tag=$2 | ||
shift | ||
;; | ||
--target) | ||
target=$2 | ||
shift | ||
;; | ||
--to) | ||
dest=$2 | ||
shift | ||
;; | ||
*) | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
need curl | ||
need install | ||
need mkdir | ||
need mktemp | ||
need tar | ||
need unzip | ||
|
||
if [ -z "${tag-}" ]; then | ||
need grep | ||
need cut | ||
fi | ||
|
||
if [ -z "${target-}" ]; then | ||
need cut | ||
fi | ||
|
||
if [ -z "${dest-}" ]; then | ||
dest="~/local/bin" | ||
fi | ||
|
||
if [ -z "${tag-}" ]; then | ||
tag=$( | ||
curl --proto =https --tlsv1.2 -sSf \ | ||
https://api.github.com/repos/dora-rs/dora/releases/latest | | ||
grep tag_name | | ||
cut -d'"' -f4 | ||
) | ||
fi | ||
|
||
if [ -z "${target-}" ]; then | ||
# bash compiled with MINGW (e.g. git-bash, used in github windows runners), | ||
# unhelpfully includes a version suffix in `uname -s` output, so handle that. | ||
# e.g. MINGW64_NT-10-0.19044 | ||
kernel=$(uname -s | cut -d- -f1) | ||
uname_target="$(uname -m)-$kernel" | ||
|
||
case $uname_target in | ||
aarch64-Linux) target=aarch64-Linux;; | ||
arm64-Darwin) target=aarch64-macOS;; | ||
x86_64-Darwin) target=x86_64-macOS;; | ||
x86_64-Linux) target=x86_64-Linux;; | ||
x86_64-MINGW64_NT) target=x86_64-Windows;; | ||
x86_64-Windows_NT) target=x86_64-Windows;; | ||
*) | ||
# shellcheck disable=SC2016 | ||
err 'Could not determine target from output of `uname -m`-`uname -s`, please use `--target`:' "$uname_target" | ||
;; | ||
esac | ||
fi | ||
|
||
case $target in | ||
x86_64-Windiws) extension=zip; need unzip;; | ||
*) extension=zip; need unzip;; | ||
esac | ||
|
||
archive="$releases/download/$tag/$crate-$tag-$target.$extension" | ||
|
||
say "Repository: $url" | ||
say "Crate: $crate" | ||
say "Tag: $tag" | ||
say "Target: $target" | ||
say "Destination: $dest" | ||
say "Archive: $archive" | ||
|
||
td=$(mktemp -d || mktemp -d -t tmp) | ||
|
||
if [ "$extension" = "zip" ]; then | ||
curl --proto =https --tlsv1.2 -sSfL "$archive" > "$td/dora.zip" | ||
unzip -d "$td" "$td/dora.zip" | ||
else | ||
curl --proto =https --tlsv1.2 -sSfL "$archive" | tar -C "$td" -xz | ||
fi | ||
|
||
if [ -e "$dest/dora" ] && [ "$force" = false ]; then | ||
err "\`$dest/dora\` already exists" | ||
else | ||
mkdir -p "$dest" | ||
install -m 755 "$td/dora" "$dest" | ||
fi | ||
|
||
rm -rf "$td" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import typing | ||
|
||
@typing.final | ||
class Enum: | ||
"""Generic enumeration. | ||
Derive from this class to define new enumerations.""" | ||
__members__: mappingproxy = ... | ||
|
||
@typing.final | ||
class Node: | ||
"""The custom node API lets you integrate `dora` into your application. | ||
It allows you to retrieve input and send output in any fashion you want. | ||
Use with: | ||
```python | ||
from dora import Node | ||
node = Node() | ||
```""" | ||
|
||
def __init__(self, /) -> None: | ||
"""The custom node API lets you integrate `dora` into your application. | ||
It allows you to retrieve input and send output in any fashion you want. | ||
Use with: | ||
```python | ||
from dora import Node | ||
node = Node() | ||
```""" | ||
|
||
def dataflow_descriptor(self, /) -> Dict: | ||
"""Returns the full dataflow descriptor that this node is part of. | ||
This method returns the parsed dataflow YAML file.""" | ||
|
||
def merge_external_events(self, /): | ||
|
||
def next(self, /) -> PyEvent: | ||
"""`.next()` gives you the next input that the node has received. | ||
It blocks until the next event becomes available. | ||
It will return `None` when all senders has been dropped. | ||
```python | ||
event = node.next() | ||
``` | ||
You can also iterate over the event stream with a loop | ||
```python | ||
for event in node: | ||
match event["type"]: | ||
case "INPUT": | ||
match event["id"]: | ||
case "image": | ||
```""" | ||
|
||
def send_output(self, /) -> None: | ||
"""`send_output` send data from the node. | ||
```python | ||
Args: | ||
output_id: str, | ||
data: Bytes|Arrow, | ||
metadata: Option[Dict], | ||
``` | ||
```python | ||
node.send_output("string", b"string", {"open_telemetry_context": "7632e76"}) | ||
```""" | ||
|
||
def __iter__(self, /) -> None: | ||
"""Implement iter(self).""" | ||
|
||
def __next__(self, /) -> None: | ||
"""Implement next(self).""" | ||
|
||
def start_runtime() -> None: | ||
"""Start a runtime for Operators""" |
Oops, something went wrong.