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

Fix empty streams as result #582

Merged
merged 5 commits into from
Oct 21, 2022
Merged

Fix empty streams as result #582

merged 5 commits into from
Oct 21, 2022

Conversation

DieMyst
Copy link
Member

@DieMyst DieMyst commented Oct 20, 2022

Handle returning streams in ArrowSem, because they will be processed and canonicalized later in inliners

fixes LNG-83
fixes LNG-84

@DieMyst DieMyst requested a review from alari October 20, 2022 09:38
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2022

Aqua version is v0.0.1-fix-empty-streams-47aca0f-72-1.0

To install it run:

npm login --registry https://npm.fluence.dev
npm i @fluencelabs/aqua@=v0.0.1-fix-empty-streams-47aca0f-72-1.0 --registry=https://npm.fluence.dev

@linear
Copy link

linear bot commented Oct 20, 2022

LNG-83 Push to stream doesn't work with assigned streams

Aqua:

func emptySugar() -> ?string:
  strStream = *["123", "777"]
  strStream <<- "345"
  <- strStream

Air:

                     (new $strStream
                        (seq
                         (seq
                          (seq
                           (ap "123" $stream-inline)
                           (ap "777" $stream-inline)
                          )
                          (ap "345" $strStream)
                         )
                         (call %init_peer_id% ("op" "identity") [$stream-inline] strStream-fix)

there is a mess with variable names

LNG-84 Function with only stream creation generate incorrect air

aqua:

func emptySugar() -> *string:
  strEmptyStream: *string
  <- strEmptyStream

air:

                    (xor
                     (seq
                      (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
                      (xor
                       (call %init_peer_id% ("callbackSrv" "response") [$strEmptyStream])
                       (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
                      )
                     )
                     (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
                    )

there is no new expression for strEmptyStream

@@ -179,8 +179,14 @@ object TagInliner extends Logging {
}

case AssignmentTag(value, assignTo) =>
// add name to CollectionRaw for streams to resolve them
Copy link
Member

Choose a reason for hiding this comment

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

I can't get this message

)
streamName <-
raw.boxType match {
case _: StreamType => raw.assignToName.map(s => State.pure(s)).getOrElse(Mangler[S].findAndForbidName("stream-inline"))
Copy link
Member

Choose a reason for hiding this comment

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

This CollectionRawInliner has a very specific callsite where you already have this assignToName in scope, I suppose

case _ => false
}

_ = println("out decl streams: " + outsideDeclaredStreams)
Copy link
Member

Choose a reason for hiding this comment

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

Plz remove debug output

_ = println("out decl streams: " + outsideDeclaredStreams)

// Function's internal variables will not be available outside, hence the scope
result <- Exports[S].scope(
Copy link
Member

Choose a reason for hiding this comment

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

Maybe

Exports[S].exports
  .map(_.collect{case a@(_, VarModel(_, StreamType(_), _)) => a})
  .flatMap(outsideDeclaredStreams  =>
    Exports[S].scope...
)

would be more readable than a for loop?

(value match {
// if we assign collection to a stream, we must use it's name, because it is already created with 'new'
case c@CollectionRaw(_, _: StreamType) =>
collectionToModel(c, Some(assignTo))
Copy link
Member

Choose a reason for hiding this comment

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

Do you ever call collectionToModel(..., None)?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, in unfold

@DieMyst DieMyst merged commit 61f483e into main Oct 21, 2022
@DieMyst DieMyst deleted the fix-empty-streams branch October 21, 2022 19:16
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.

None yet

2 participants