Skip to content

Commit

Permalink
dont upload output to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
sushant12 committed Oct 29, 2024
1 parent ae239ec commit 19e93c0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 64 deletions.
63 changes: 31 additions & 32 deletions lib/handin/assignment_submission_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ defmodule Handin.AssignmentSubmissionServer do
defp build_all_scripts(state) do
build_main_script(state.assignment) ++
build_file_download_script(state.assignment, state.user_id) ++
build_upload_script(state.assignment, state) ++
build_check_script(state.assignment) ++
build_tests_scripts(state.assignment)
end
Expand Down Expand Up @@ -386,37 +385,37 @@ defmodule Handin.AssignmentSubmissionServer do
]
end

defp build_upload_script(assignment, state) do
config = ExAws.Config.new(:s3, Application.get_all_env(:ex_aws))

template = """
#!/bin/bash
"""

curls =
assignment.assignment_tests
|> Enum.map(fn assignment_test ->
{:ok, presigned_url} =
ExAws.S3.presigned_url(
config,
:put,
"handin-dev",
"uploads/assignments/#{assignment.id}/users/#{state.user_id}/submission/#{assignment_test.id}.out",
expires_in: 6000
)

"curl --request PUT --upload-file \"#{assignment_test.id}.out\" \"#{presigned_url}\""
end)

template = template <> Enum.join(curls, "\n")

[
%{
"guest_path" => "/upload.sh",
"raw_value" => Base.encode64(template)
}
]
end
# defp build_upload_script(assignment, state) do
# config = ExAws.Config.new(:s3, Application.get_all_env(:ex_aws))

# template = """
# #!/bin/bash
# """

# curls =
# assignment.assignment_tests
# |> Enum.map(fn assignment_test ->
# {:ok, presigned_url} =
# ExAws.S3.presigned_url(
# config,
# :put,
# "handin-dev",
# "uploads/assignments/#{assignment.id}/users/#{state.user_id}/submission/#{assignment_test.id}.out",
# expires_in: 6000
# )

# "curl --request PUT --upload-file \"#{assignment_test.id}.out\" \"#{presigned_url}\""
# end)

# template = template <> Enum.join(curls, "\n")

# [
# %{
# "guest_path" => "/upload.sh",
# "raw_value" => Base.encode64(template)
# }
# ]
# end

defp build_tests_scripts(assignment) do
assignment.assignment_tests
Expand Down
63 changes: 31 additions & 32 deletions lib/handin/build_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ defmodule Handin.BuildServer do
defp build_all_scripts(state) do
build_main_script(state.assignment) ++
build_file_download_script(state.assignment) ++
build_upload_script(state.assignment, state) ++
build_check_script(state.assignment) ++
build_tests_scripts(state.assignment)
end
Expand Down Expand Up @@ -369,37 +368,37 @@ defmodule Handin.BuildServer do
]
end

defp build_upload_script(assignment, state) do
config = ExAws.Config.new(:s3, Application.get_all_env(:ex_aws))

template = """
#!/bin/bash
"""

curls =
assignment.assignment_tests
|> Enum.map(fn assignment_test ->
{:ok, presigned_url} =
ExAws.S3.presigned_url(
config,
:put,
"handin-dev",
"uploads/assignments/#{assignment.id}/users/#{state.user_id}/submission/#{assignment_test.id}.out",
expires_in: 6000
)

"curl --request PUT --upload-file \"#{assignment_test.id}.out\" \"#{presigned_url}\""
end)

template = template <> Enum.join(curls, "\n")

[
%{
"guest_path" => "/upload.sh",
"raw_value" => Base.encode64(template)
}
]
end
# defp build_upload_script(assignment, state) do
# config = ExAws.Config.new(:s3, Application.get_all_env(:ex_aws))

# template = """
# #!/bin/bash
# """

# curls =
# assignment.assignment_tests
# |> Enum.map(fn assignment_test ->
# {:ok, presigned_url} =
# ExAws.S3.presigned_url(
# config,
# :put,
# "handin-dev",
# "uploads/assignments/#{assignment.id}/users/#{state.user_id}/submission/#{assignment_test.id}.out",
# expires_in: 6000
# )

# "curl --request PUT --upload-file \"#{assignment_test.id}.out\" \"#{presigned_url}\""
# end)

# template = template <> Enum.join(curls, "\n")

# [
# %{
# "guest_path" => "/upload.sh",
# "raw_value" => Base.encode64(template)
# }
# ]
# end

defp build_tests_scripts(assignment) do
assignment.assignment_tests
Expand Down

0 comments on commit 19e93c0

Please sign in to comment.