-
Notifications
You must be signed in to change notification settings - Fork 0
Prepare procedure source URL for remote tarballs #92
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
Conversation
8W9aG
commented
Jun 9, 2025
- If someone has a URL path for a procedure that contains multiple directories this currently fail
- Hash the path so the directories are standardised
internal/server/server.go
Outdated
@@ -203,7 +205,8 @@ func (h *Handler) Predict(w http.ResponseWriter, r *http.Request) { | |||
http.Error(w, "invalid procedure_source_url", http.StatusBadRequest) | |||
return | |||
} | |||
srcDir := u.Path | |||
hash := md5.Sum([]byte(u.Path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use SHA256 in most places. Do that for consistency? Performance is not an issue here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were assuming req.ProcedureSourceURL
was a file:///<path>
type local path that already exists.
But here we should probably dome something like:
var srcDir string
if u.Scheme == "file" {
srcDir = u.Path
}
else {
// URL is (http|https)://...
sha := <sha sum of URL>
srcDir = path.Join(os.TempDir(), "procedure-" + sha)
os.MkdirAll(srcDir)
<pget -x URL srcDir>
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pget -x <URL> <dir>
creates the <dir>
so don't even need os.MkdirAll
internal/server/runner.go
Outdated
@@ -120,6 +120,7 @@ func NewRunner(awaitExplicitShutdown bool, uploadUrl string) *Runner { | |||
|
|||
func NewProcedureRunner(awaitExplicitShutdown bool, uploadUrl string, srcDir string) *Runner { | |||
r := NewRunner(awaitExplicitShutdown, uploadUrl) | |||
os.Mkdir(srcDir, 0o755) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this to server.go
where we hash URL & extract tarball. Runner should always assume dir is prepared.
* If someone has a URL path for a procedure that contains multiple directories this currently fail * Hash the path so the directories are standardised
4f8d514
to
f870ab9
Compare
d7508d1
to
3f985d8
Compare
3f985d8
to
e10a9c9
Compare