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

627 support for streaming via stdio #50

Merged
merged 26 commits into from
Feb 7, 2024

Conversation

kidq330
Copy link
Contributor

@kidq330 kidq330 commented Jan 9, 2024

No description provided.

@kidq330 kidq330 requested a review from varsill January 9, 2024 13:26
@kidq330 kidq330 linked an issue Jan 9, 2024 that may be closed by this pull request
@kidq330
Copy link
Contributor Author

kidq330 commented Jan 9, 2024

Weird finding while fixing the MIX_ENV bug:

root@d326e438f233:~/project# mix test
Generated membrane_file_plugin app
..............................

  1) test pipeline from :stdin to file works when content is longer than chunk_size (Membrane.File.Integration.StdioTest)
     test/integration/stdio_test.exs:37
     Assertion with == failed
     code:  assert {"", _rc = 0} ==
              System.shell(
                "bash -c '                                                                                              set -o pipefail;                                                                                       cat #{@input_text_file} | mix run test/fixtures/pipe_to_file.exs #{cmd_out} 5'                        2> #{cmd_err}",
                env: [{"MIX_QUIET", "true"}, {"MIX_ENV", "dev"}]
              )
     left:  {"", 0}
     right: {"src/parser.yrl: Warning: conflicts: 27 shift/reduce, 0 reduce/reduce\n", 0}
     stacktrace:
       test/integration/stdio_test.exs:39: (test)

...
Finished in 47.1 seconds (0.5s async, 46.6s sync)
34 tests, 1 failure

Randomized with seed 913776
root@d326e438f233:~/project# mix test
..................................
Finished in 8.8 seconds (0.4s async, 8.4s sync)
34 tests, 0 failures

Randomized with seed 246311

config/config.exs Show resolved Hide resolved
examples/sink_and_source.exs Outdated Show resolved Hide resolved
lib/membrane_file/sink.ex Show resolved Hide resolved
lib/membrane_file/source.ex Show resolved Hide resolved
test/fixtures/file_to_pipe.exs Outdated Show resolved Hide resolved
test/integration/stdio_test.exs Show resolved Hide resolved
test/integration/stdio_test.exs Outdated Show resolved Hide resolved
test/integration/stdio_test.exs Outdated Show resolved Hide resolved
test/integration/stdio_test.exs Outdated Show resolved Hide resolved
lib/membrane_file/source.ex Show resolved Hide resolved
@varsill
Copy link
Contributor

varsill commented Jan 10, 2024

Great! I have left some doubts and suggestions in the comments ;) Apart from that, as far as I can see, one of the new tests is failing on the CI

lib/membrane_file/sink.ex Outdated Show resolved Hide resolved
test/integration/stdio_test.exs Show resolved Hide resolved
Copy link
Contributor

@varsill varsill left a comment

Choose a reason for hiding this comment

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

Great, I have spotted just a one opportunity for improvement in case of the documentation

lib/membrane_file/source.ex Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

This requires to be run within a mix project. Let's add Mix.install so it can be run with elixir file_to_pipe.exs

@@ -0,0 +1,19 @@
import Membrane.ChildrenSpec
import Membrane.Testing.Assertions
alias Membrane.Testing.Pipeline
Copy link
Member

Choose a reason for hiding this comment

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

This is intended to be used in tests, let's use a regular pipeline or Membrane.RCPipeline instead

Comment on lines 14 to 32
# def yes?(_message, _opts \\ []), do: :ok

# def cmd(command, opts \\ []) do
# Mix.Shell.cmd(command, opts, fn data -> data end)
# end
# end

# {:ok, config} = :logger.get_handler_config(:default)
# config_dev = put_in(config, [:config, :type], :standard_error)

# :ok =
# :logger.set_handler_config(:default, put_in(config, [:config, :type], :standard_error))

# :logger.remove_handler(:default)
# :ok =
# :logger.add_handler(:default, :logger_std_h, put_in(config, [:config, :type], :standard_error))

# Logger.configure(device: :standard_error)
# Logger.Backends.Internal.configure(device: :standard_error)
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this is finished? :P

@kidq330 kidq330 requested a review from mat-hek January 24, 2024 14:28
lib/membrane_file/sink.ex Outdated Show resolved Hide resolved
# currently also requires 'configure: :logger, backends: []' line in config.exs
LoggerBackends.add(LoggerBackends.Console)
LoggerBackends.configure(LoggerBackends.Console, device: :standard_error)
Mix.install([{:membrane_file_plugin, path: "."}])
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it be path: "../"? I believe we are in the examples/ subdirectory

mix.exs Outdated
Comment on lines 82 to 113
# Also, a small bug noticed when reproducing on elixir 1.16.0, this time related to mix:
# ```elixir
# require Logger

# Mix.start()
# Mix.shell(Mix.Shell.Quiet)

# Mix.install(
# [
# :ratio,
# :logger_backends
# ],
# force: true
# )
# ```
# ```command
# root@5da670a83b2e:/workspace/membrane/logger_mre# elixirc mre.exs 2> stderr.log
# ==> ratio
# ```
# stderr.log:
# ```log
# Every 2.0s: cat stderr.log 5da670a83b2e: Tue Jan 30 12:35:47 2024

# warning: Ratio.DecimalConversion.decimal_to_rational/1 is undefined (module Ratio.DecimalConversion is not availabl
# e or is yet to be defined)
# │
# 17 │ {ratio, Ratio.DecimalConversion.decimal_to_rational(decimal)}
# │ ~
# │
# └─ lib/ratio/coerce.ex:17:37: Coerce.Implementations.Ratio.Decimal.coerce/2

# both :extra_applications and :applications was found in your mix.exs. You most likely want to remove the :applications
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 we can remove this one (I believe it's good to describe such problematic cases for instance in the PR's description).
However, we can warn user in the example description, that in case there are some warnings thrown during the compilation, the example might not work.

lib/membrane_file/sink.ex Show resolved Hide resolved
@kidq330 kidq330 requested a review from varsill February 7, 2024 10:25
Copy link
Contributor

@varsill varsill left a comment

Choose a reason for hiding this comment

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

🥇

@kidq330 kidq330 merged commit 669c2a8 into master Feb 7, 2024
3 checks passed
@kidq330 kidq330 deleted the 627-support-for-streaming-via-stdio branch February 7, 2024 10:29
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.

Support for streaming via stdio
3 participants