Skip to content

Commit

Permalink
Expand env value when possible
Browse files Browse the repository at this point in the history
This commit enables users to pass environment variable as composition
of env variable such as:

```yaml
  - id: yolov5
    operator:
      outputs:
        - bbox
        - ready
      inputs:
        image: oasis_agent/image
        check: oasis_agent/yolov5_check
      python: ../../operators/yolov5_op.py
    env:
      YOLOV5_PATH: $HOME/Documents/dependencies/yolov5
      YOLOV5_WEIGHT_PATH: $DORA_DEP_HOME/dependencies/yolov5/yolov5n.pt
```

Note that this is only for the env field. Expanding env variable for
source path might conflict with using url as source path.
  • Loading branch information
haixuanTao committed Feb 15, 2023
1 parent 40b715e commit 933dadc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libraries/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ once_cell = "1.13.0"
zenoh-config = { git = "https://github.com/eclipse-zenoh/zenoh.git", rev = "79a136e4fd90b11ff5d775ced981af53c4f1071b" }
which = "4.3.0"
uuid = { version = "1.2.1", features = ["serde"] }
serde-with-expand-env = "1.1.0"
4 changes: 4 additions & 0 deletions libraries/core/src/descriptor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::config::{CommunicationConfig, DataId, InputMapping, NodeId, NodeRunConfig, OperatorId};
use eyre::{bail, Result};
use serde::{Deserialize, Serialize};
use serde_with_expand_env::with_expand_envs;
use std::{
collections::{BTreeMap, BTreeSet, HashMap},
env::consts::EXE_EXTENSION,
Expand Down Expand Up @@ -222,8 +223,11 @@ pub struct CustomNode {
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EnvValue {
#[serde(deserialize_with = "with_expand_envs")]
Bool(bool),
#[serde(deserialize_with = "with_expand_envs")]
Integer(u64),
#[serde(deserialize_with = "with_expand_envs")]
String(String),
}

Expand Down

0 comments on commit 933dadc

Please sign in to comment.