Browse Source

fix CI and make CI job non-interactive

tags/v0.0.0-test.4
haixuanTao 3 years ago
parent
commit
a52bbec30b
6 changed files with 29 additions and 19 deletions
  1. +5
    -2
      .github/workflows/ci-python.yml
  2. +1
    -1
      examples/python-dataflow/dataflow_without_webcam.yml
  3. +3
    -3
      examples/python-dataflow/no_webcam.py
  4. +2
    -4
      examples/python-dataflow/object_detection.py
  5. +10
    -7
      examples/python-dataflow/plot.py
  6. +8
    -2
      examples/python-dataflow/run.rs

+ 5
- 2
.github/workflows/ci-python.yml View File

@@ -23,5 +23,8 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: 3.8.10
- name: "Install python dependencies"
run: examples/python-dataflow/install.sh
- name: "Python Dataflow example"
uses: actions-rs/cargo@v1
with:
command: run
args: --example python-dataflow

+ 1
- 1
examples/python-dataflow/dataflow_without_webcam.yml View File

@@ -1,6 +1,6 @@
communication:
zenoh:
prefix: /example-python-dataflow
prefix: /example-python-no-webcam-dataflow

nodes:
- id: no_webcam


+ 3
- 3
examples/python-dataflow/no_webcam.py View File

@@ -8,9 +8,7 @@ import cv2
import numpy as np
from dora import Node

req = urllib.request.urlopen(
"https://pyimagesearch.com/wp-content/uploads/2015/01/opencv_logo.png"
)
req = urllib.request.urlopen("https://ultralytics.com/images/zidane.jpg")

arr = np.asarray(bytearray(req.read()), dtype=np.uint8)
node = Node()
@@ -21,3 +19,5 @@ while time.time() - start < 20:
# Wait next input
node.next()
node.send_output("image", arr.tobytes())

time.sleep(1)

+ 2
- 4
examples/python-dataflow/object_detection.py View File

@@ -13,9 +13,7 @@ class DoraStatus(Enum):

class Operator:
"""
Example operator incrementing a counter every times its been called.

The current value of the counter is sent back to dora on `counter`.
Infering object from images
"""

def __init__(self):
@@ -27,7 +25,7 @@ class Operator:
value: bytes,
send_output: Callable[[str, bytes], None],
) -> DoraStatus:
"""Handle input by incrementing count by one.
"""Handle image

Args:
input_id (str): Id of the input declared in the yaml configuration


+ 10
- 7
examples/python-dataflow/plot.py View File

@@ -1,9 +1,12 @@
import os
from enum import Enum
from typing import Callable

import cv2
import numpy as np

CI = os.environ.get("CI")


class DoraStatus(Enum):
CONTINUE = 0
@@ -12,9 +15,7 @@ class DoraStatus(Enum):

class Operator:
"""
Example operator incrementing a counter every times its been called.

The current value of the counter is sent back to dora on `counter`.
Plot image and bounding box
"""

def __init__(self):
@@ -26,7 +27,8 @@ class Operator:
value: bytes,
send_output: Callable[[str, bytes], None],
) -> DoraStatus:
"""Handle input by incrementing count by one.
"""
Put image and bounding box on cv2 window.

Args:
input_id (str): Id of the input declared in the yaml configuration
@@ -57,9 +59,10 @@ class Operator:
(0, 255, 0),
2,
)
cv2.imshow("frame", self.image)
if cv2.waitKey(1) & 0xFF == ord("q"):
return DoraStatus.STOP
if CI != "true":
cv2.imshow("frame", self.image)
if cv2.waitKey(1) & 0xFF == ord("q"):
return DoraStatus.STOP

return DoraStatus.CONTINUE



+ 8
- 2
examples/python-dataflow/run.rs View File

@@ -1,5 +1,5 @@
use eyre::{bail, Context};
use std::path::Path;
use std::{env, path::Path};

#[tokio::main]
async fn main() -> eyre::Result<()> {
@@ -11,8 +11,14 @@ async fn main() -> eyre::Result<()> {

install_python_dependencies(root).await?;

let dataflow = if env::var("CI").is_ok() {
Path::new("dataflow_without_webcam.yml").to_owned()
} else {
Path::new("dataflow.yml").to_owned()
};

dora_coordinator::run(dora_coordinator::Command::Run {
dataflow: Path::new("dataflow.yml").to_owned(),
dataflow,
runtime: Some(root.join("target").join("release").join("dora-runtime")),
})
.await?;


Loading…
Cancel
Save