-
Notifications
You must be signed in to change notification settings - Fork 5
Add decoding and encoding to string for Graph #5
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,4 @@ erl_crash.dump | |
| imageflow_ex-*.tar | ||
|
|
||
| native/imageflow_ex/target/ | ||
| priv/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,36 @@ | ||
| defmodule Imageflow.GraphRunner do | ||
| alias Imageflow.{Graph, Native} | ||
| alias Imageflow.{Graph, Native, Result} | ||
|
|
||
| def run(%Graph{} = graph) do | ||
| with {:ok, job} <- Native.create(), | ||
| :ok <- add_inputs(job, graph.inputs), | ||
| :ok <- add_outputs(job, graph.outputs), | ||
| :ok <- send_task(job, graph), | ||
| :ok <- save_outputs(job, graph.outputs), | ||
| :ok <- Native.destroy(job) do | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems this step got left out entirely. |
||
| :ok | ||
| :ok <- save_outputs(job, graph.outputs) do | ||
| {:ok, job, graph} | ||
| end | ||
| end | ||
|
|
||
| def get_results(job, %Graph{outputs: outputs} = graph) do | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know I'm the one who suggested this function in the first place, but the API doesn't look correct. As per Elixir standards, Also, coupling this with my other comment about |
||
| outputs | ||
| |> Enum.reduce_while({:ok, []}, fn {id, value}, {:ok, _acc} -> | ||
| case value do | ||
| :bytes -> | ||
| case Native.get_output_buffer(job, id) do | ||
| {:ok, results} -> {:cont, {:ok, :binary.list_to_bin(results)}} | ||
| {:error, _} = error -> {:halt, error} | ||
| end | ||
|
|
||
| {:file, path} -> | ||
| {:cont, {:ok, path}} | ||
| end | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might be missreading this, but isnt' this resulting in an |
||
| end) | ||
| |> case do | ||
| {:ok, results} -> | ||
| {:ok, %Result{job: job, graph: graph, output: results}} | ||
|
|
||
| error -> | ||
| error | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -18,6 +40,7 @@ defmodule Imageflow.GraphRunner do | |
| {id, value}, :ok -> | ||
| case value do | ||
| {:file, path} -> Native.add_input_file(job, id, path) | ||
| {:bytes, blob} -> Native.add_input_buffer(job, id, blob) | ||
| end | ||
| |> case do | ||
| :ok -> {:cont, :ok} | ||
|
|
@@ -44,6 +67,8 @@ defmodule Imageflow.GraphRunner do | |
| {id, value}, :ok -> | ||
| case value do | ||
| {:file, path} -> Native.save_output_to_file(job, id, path) | ||
| # skip | ||
| :bytes -> :ok | ||
| end | ||
| |> case do | ||
| :ok -> {:cont, :ok} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| defmodule Imageflow.Result do | ||
| defstruct job: nil, graph: nil, output: nil | ||
| end |
Uh oh!
There was an error while loading. Please reload this page.