Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate yaml when reading #237

Merged
merged 8 commits into from
Mar 31, 2023
Merged

Validate yaml when reading #237

merged 8 commits into from
Mar 31, 2023

Conversation

haixuanTao
Copy link
Collaborator

@haixuanTao haixuanTao commented Mar 27, 2023

This PR validates YAML when been read avoiding typo and undefined behaviour.

The implementation is done as follows:

  • On commit db92865 , it reduce the repetition of read_description and address it with read and blocking_read (inspired by tokio) as a method of dora_core::Descriptor.
  • On commit 704d8db , it moves the dora_cli::check yaml logic into a dora_core logic.
  • On commit de5a333 , it makes the validation optional, and only done if is_valid is called. This is because some function requires to read the dataflow even if its not valid such as graph and build

This Pull Request avoid hanging on inputs that does not exist. Such as mistyped node_id or outputs. It will generates the following error:

Error: failed to read dataflow at `dataflow.yml`

Caused by:
    source node `webcam_unknown_name` mapped to input `op/object_detection/image` does not exist

Location:
    libraries/core/src/descriptor/validate.rs:117:17

and:

Error: failed to read dataflow at `dataflow.yml`

Caused by:
    output `webcam/unknown_output` mapped to input `op/object_detection/image` does not exist

Location:
    libraries/core/src/descriptor/validate.rs:122:25

@haixuanTao haixuanTao changed the title Validate yaml when reading to avoid undefined behaviour Validate yaml when reading Mar 27, 2023
Copy link
Collaborator

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

libraries/core/src/descriptor/mod.rs Outdated Show resolved Hide resolved
libraries/core/src/descriptor/mod.rs Outdated Show resolved Hide resolved
binaries/cli/src/main.rs Outdated Show resolved Hide resolved
libraries/core/src/descriptor/validate.rs Outdated Show resolved Hide resolved
libraries/core/src/descriptor/mod.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@phil-opp phil-opp merged commit f53fe65 into main Mar 31, 2023
@phil-opp phil-opp deleted the validate-yaml branch March 31, 2023 09:49
haixuanTao added a commit that referenced this pull request Apr 1, 2023
In #237, I have grouped the validation of yaml as a method of descriptor.

This validation was copied from the `cli check` method. However, we did not
add the validation of shell command and accept url as valid source in the
original `cli check`.

This Pull Request validate both sources.
haixuanTao added a commit that referenced this pull request Apr 4, 2023
In #237, I have grouped the validation of yaml as a method of descriptor.

This validation was copied from the `cli check` method. However, we did not
add the validation of shell command and accept url as valid source in the
original `cli check`.

This Pull Request validate both sources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants