Skip to content

Commit

Permalink
Make it possible to check the logs without passing uuid
Browse files Browse the repository at this point in the history
This commit make it possible to check the logs as follows:

```bash
dora logs object_detection
```

If more than one dataflow is running, we will inquire for which dataflow to use.
  • Loading branch information
haixuanTao committed Jan 26, 2024
1 parent cb74ee1 commit a5ad3c7
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions binaries/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ enum Command {
// Planned for future releases:
// Dashboard,
/// Show logs of a given dataflow and node.
Logs { dataflow: String, node: String },
Logs {
dataflow_or_node: String,
node: Option<String>,
},
// Metrics,
// Stats,
// Get,
Expand Down Expand Up @@ -191,12 +194,29 @@ fn run() -> eyre::Result<()> {
internal_create_with_path_dependencies,
} => template::create(args, internal_create_with_path_dependencies)?,
Command::Up { config } => up::up(config.as_deref())?,
Command::Logs { dataflow, node } => {
let uuid = Uuid::parse_str(&dataflow).ok();
let name = if uuid.is_some() { None } else { Some(dataflow) };

Command::Logs {
dataflow_or_node,
node,
} => {
let mut session =
connect_to_coordinator().wrap_err("failed to connect to dora coordinator")?;
logs::logs(&mut *session, uuid, name, node)?
let uuids = query_running_dataflows(&mut *session)
.wrap_err("failed to query running dataflows")?;
if let Some(node) = node {
let dataflow = dataflow_or_node;
let uuid = Uuid::parse_str(&dataflow).ok();
let name = if uuid.is_some() { None } else { Some(dataflow) };
logs::logs(&mut *session, uuid, name, node)?
} else {
let uuid = match &uuids[..] {
[] => bail!("No dataflows are running"),
[uuid] => uuid.clone(),
_ => inquire::Select::new("Choose dataflow to show logs:", uuids).prompt()?,
};
let node = dataflow_or_node;
logs::logs(&mut *session, Some(uuid.uuid), None, node)?
}
}
Command::Start {
dataflow,
Expand Down

0 comments on commit a5ad3c7

Please sign in to comment.