Skip to content

Conversation

@oleksandrvoyager
Copy link
Member

No description provided.

@oleksandrvoyager oleksandrvoyager self-assigned this Nov 26, 2024
@oleksandrvoyager oleksandrvoyager changed the title Add example flows (top-level) Add example flows (top-level)/(metacrate) Nov 29, 2024
@oleksandrvoyager oleksandrvoyager changed the title Add example flows (top-level)/(metacrate) Add example flows (top-level) / (metacrate) Nov 29, 2024
Copy link
Member

@SamuelSarle SamuelSarle left a comment

Choose a reason for hiding this comment

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

LGTM although for some reason I'm unable to run these:

  • examples/csv_roundtrip.rs
  • examples/hash_content.rs
  • examples/log_directories.rs

Were you able to run those? They give import errors that I haven't been able to solve for TextBlocks::concat_strings_by, TextBlocks::decode_csv, TextBlocks::encode_csv, and HashBlocks::hash_sha2.
Specifically that would be the implementations missing for protoflow_blocks::System but of course all of those are present in the repo (lib/protoflow-blocks/src/system.rs)

Examples:

error[E0599]: no method named `encode_csv` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope
error[E0599]: no method named `decode_csv` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope
error[E0599]: no method named `hash_sha2` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope
error[E0599]: no method named `concat_strings_by` found for mutable reference `&mut protoflow::protoflow_blocks::System` in the current scope

Comment on lines +7 to +10
let json = s.const_string(r#"{"Name": "Alice","Age": 25,"Score": 90}"#);

let line_encoder = s.encode_lines();
s.connect(&json.output, &line_encoder.input);
Copy link
Member

Choose a reason for hiding this comment

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

In the future we should probably implement a Const helper which can output Bytes from a string. This behaves correctly but the line_encoder looks a bit funny here :)

Comment on lines +7 to +10
let input_string = s.const_string("The quick brown fox jumps over the lazy dog");

let encoder = s.encode_lines();
s.connect(&input_string.output, &encoder.input);
Copy link
Member

Choose a reason for hiding this comment

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

Likewise for here as hex("$string\n") != hex("$string")

Comment on lines +7 to +13
let input_string = s.const_string("54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f670a");

let encoder = s.encode_lines();
s.connect(&input_string.output, &encoder.input);

let hex_decoder = s.decode_hex();
s.connect(&encoder.output, &hex_decoder.input);
Copy link
Member

Choose a reason for hiding this comment

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

Same problem, with interesting behaviour with DecodeHex! This appends a newline at the end before sending it to DecodeHex which should result in an error. But DecodeHex uses Bytes::chunks_exact(2) which leaves the newline character alone as it's one byte:

The chunks are slices and do not overlap. If chunk_size does not divide the length of the
slice, then the last up to chunk_size-1 elements will be omitted and can be retrieved
from the remainder function of the iterator.

I think that DecodeHex shouldn't accept and ignore the last byte silently so we should make a PR so that it checks the content length is divisible by two.

Comment on lines +13 to +15
let content = s.const_string("Hello, World!");
let line_encoder = s.encode_lines();
let hash_content = s.hash_sha2();
Copy link
Member

Choose a reason for hiding this comment

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

Not able to run this file directly but copying the code to somewhere else you get

$ echo "Hello, World!" | sha256sum
c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31

instead of the correct

$ echo -n "Hello, World!" | sha256sum
dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f

due to the s.encode_lines() adding a newline that also gets hashed.

Co-authored-by: Samuel Sarle <[email protected]>
Signed-off-by: Oleksandr Yakovenko <[email protected]>
Co-authored-by: Samuel Sarle <[email protected]>
Signed-off-by: Oleksandr Yakovenko <[email protected]>
@artob
Copy link
Member

artob commented Jan 27, 2025

@race-of-sloths invite

@race-of-sloths
Copy link

@artob Thank you for calling!

@AlexSanches1 Thank you for the contribution! Join Race of Sloths by simply mentioning me in your comment/PRs description and start collecting Sloth Points through contributions to open source projects.

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

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.

5 participants