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

Feature/deployable #311

Merged
merged 1 commit into from
Sep 21, 2023
Merged

Feature/deployable #311

merged 1 commit into from
Sep 21, 2023

Conversation

sduchesneau
Copy link
Contributor

Added

  • Sink configs can now use protobuf annotations (aka Field Options) to determine how the field will be interpreted in
    substreams.yaml:

    • load_from_file will put the content of the file directly in the field (string and bytes contents are supported).
    • zip_from_folder will create a zip archive and put its content in the field (field type must be bytes).

    Example:

    import "sf/substreams/v1/options.proto";
    optional bytes schema = 1 [ (sf.substreams.v1.options).load_from_file = true ];`
    optional bytes extra_config_files = 2 [ (sf.substreams.v1.options).zip_from_folder = true ];`
    
  • substreams info command now properly displays the sink configs, optionally writing the bytes fields to disk with --dump-sinkconfig-bytes-to-disk flag

Removed

  • The @path/to/textfile and @@path/to/binaryfile notations under sink_configs in substreams.yaml are now DEPRECATED (they will still work but with a warning).

Comment on lines 19 to 20
optional bytes schema = 1 [ (sf.substreams.v1.options).load_from_file = true ];`
optional bytes extra_config_files = 2 [ (sf.substreams.v1.options).zip_from_folder = true ];`
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's showcase the message ... part as it's not clear like that where those are used. Would probably use a "complete" message.

manifest/sink.go Outdated
isBytes := fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_BYTES
if opts := fd.GetFieldOptions(); opts != nil {
opts.ProtoReflect().Range(func(desc protoreflect.FieldDescriptor, val protoreflect.Value) bool {
if desc.TextName() != "[sf.substreams.v1.options]" {
Copy link
Contributor

Choose a reason for hiding this comment

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

The literal is repeated, let's extract it (can we even extract from the Message directly).

manifest/sink.go Outdated
if err != nil {
return err
}
path = strings.Replace(strings.TrimPrefix(strings.TrimPrefix(path, basePath), string(filepath.Separator)), "\\", "/", -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Really hard to read and reason about

Copy link
Contributor

Choose a reason for hiding this comment

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

At the very minimum, a quick comment is required.

import "google/protobuf/descriptor.proto";

message FieldOptions {
// this flag informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a file, putting its content as bytes in this field.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// this flag informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a file, putting its content as bytes in this field.
// This option informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a file, putting its content as bytes in this field.

// must be applied to a `bytes` or `string` field
bool load_from_file = 1;

// this flag informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a folder, zipping its content and putting the zip content as bytes in this field.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// this flag informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a folder, zipping its content and putting the zip content as bytes in this field.
// This option informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a folder, zipping its content and putting the zip content as bytes in this field.

}

extend google.protobuf.FieldOptions {
optional FieldOptions options = 2200;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is a central repo that list used/unsued value here, did you see something about that?

manifest/sink.go Outdated
return nil
}

func SinkConfigAsString(pkg *pbsubstreams.Package, dumpBytesToDisk bool) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I dislike the fact that converting to string also dumps to file. In fact more reading lead me to think that this function is weirdly named.

It also deals with representational aspect, the output being a new-line separated string. The function should return a []string and let the caller decide what to do.

I also think the path where to write things should be pass in by the caller. Inferring tmp seems unecessary, the caller should deal with this decision.

…nfig

* allow `substreams info` to read sinkconfig, add output-sinkconfig-files-path flag
* changelog
@sduchesneau sduchesneau merged commit a011e07 into develop Sep 21, 2023
5 checks passed
@sduchesneau sduchesneau deleted the feature/deployable branch September 21, 2023 19:36
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