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

feat: add interface to expose HTTP ports on batch jobs #52

Merged
merged 32 commits into from
Jun 27, 2024
Merged

Conversation

mortenpi
Copy link
Member

The exact API is still WIP, and needs tests and more docs, but adds two functions right now:

First, an expose argument to JuliaHub.submit_job, that allows you to specify that a port from the job container should be exposed, e.g.:

JuliaHub.submit_job(
    JuliaHub.appbundle(@__DIR__, "run.jl"),
    expose=8080
)

It also adds a JuliaHub.request function that takes a JuliaHub.Job as an argument and constructs a HTTP.request (pretty much a wrapper around HTTP.request; close #14):

julia> myjob = JuliaHub.job("jr-jgz2xmxas6");

julia> JuliaHub.request(myjob, "GET", "/")
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 12
Connection: keep-alive
Server: openresty
Date: Fri, 24 May 2024 07:44:59 GMT
Expires: Fri, 24 May 2024 07:45:00 GMT
Cache-Control: max-age=1, no-cache

hello world!"""

method::AbstractString,
uripath::AbstractString,
body::Any = UInt8[];
auth::Authentication=__auth__(),
Copy link
Member

Choose a reason for hiding this comment

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

Should we allow for ::Nothing or similar here as well? To allow for "anonymous" access, basically.

Copy link
Member Author

Choose a reason for hiding this comment

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

In my opinion, we should only do that once we have the API to submit jobs that allow for anonymous access, otherwise it's not really consistent between the two functions. I like the API idea itself though (i.e. using nothing for that).

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, the function is a very thin wrapper around HTTP.request. So if you do want to make unauthenticated requests, you can just get the hostname from job.hostname and call HTTP.request yourself.

src/batchimages.jl Outdated Show resolved Hide resolved
@mortenpi mortenpi closed this Jun 10, 2024
@mortenpi mortenpi reopened this Jun 10, 2024
@mortenpi mortenpi marked this pull request as ready for review June 13, 2024 03:45
@mortenpi mortenpi merged commit 614c5b1 into main Jun 27, 2024
12 checks passed
@mortenpi mortenpi deleted the mp/expose-port branch June 27, 2024 10:17
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.

Helper functions for making requests against interactive API jobs
2 participants