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

Batch - Support setting the working directory #10670

Open
loicmathieu opened this issue Apr 9, 2024 · 16 comments
Open

Batch - Support setting the working directory #10670

loicmathieu opened this issue Apr 9, 2024 · 16 comments
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@loicmathieu
Copy link

Is your feature request related to a problem? Please describe.
When you create a Batch Job, there is no way to set the working directory; the documentation says to cd WORKING_DIRECTORY.
It would be convenient, especially when working with volumes, to be able to se the working directory to the volume mount path.

Describe the solution you'd like
We should be able to set the task runnable working directory or at least the container when using containers as container engine support setting the working directory.

runnableBuilder.setWorkingDirectory(MOUNT_PATH);

// OR

containerBuilder.setWorkingDirectory(MOUNT_PATH);

Describe alternatives you've considered
Using cd as a first command as the documentation explain.

@suztomo
Copy link
Member

suztomo commented Apr 9, 2024

What Maven artifact do you use?

the documentation says

Would you share URL of the document?

@loicmathieu
Copy link
Author

What Maven artifact do you use?

We're using com.google.cloud:google-cloud-batch.

The documentation I use is here: https://cloud.google.com/batch/docs/create-run-job-storage#console
It didn't explain how to change to current working directory in Java but only a general remark:
image

@suztomo
Copy link
Member

suztomo commented Apr 9, 2024

Checking

@suztomo
Copy link
Member

suztomo commented Apr 9, 2024

That "cd" command is just to demonstrate how to create a file in the persistent disk. In fact, in the gcloud example, the full path to the file is specified without "cd" command:

image

Therefore, you shouldn't be blocked by the lack of setting working directory.

@loicmathieu
Copy link
Author

Yes, I realize that, what I ask is to be able, via the Java SDK, to set the working directory.

I only refer to the cd command on the doc to explain what I want to avoid, using cd or a direct reference to the working directory.

We mount a volume in the batch job, this volume is created from a bucket where we create a random folder for each Job. We use this random folder as the mount path so we would like to set the working directory of the Job to the mount path as we upload files in the bucket before launching the job so it would be more convenient.

We have a generic task runner that can run arbitrary scripts (shell, Python, Julia, ...) in a lot of different platform including Google Cloud so we need to offer a coherent way of working on all environments and the user of our tasks runner doesn't know anything about Google Batch or any other supported task runner.

@suztomo
Copy link
Member

suztomo commented Apr 9, 2024

a generic task runner

I'd like to know more about the abstraction. Is that Docker containers (e.g., https://cloud.google.com/batch/docs/samples/batch-create-container-job)?

@loicmathieu
Copy link
Author

Yes we use container Job.

The abstraction that our user use are very high level, they describe a task in YAML and a runner (Docker, k8s, Google Batch, AWS Batch, ...) and we create the needed resources on the target runner.

@suztomo
Copy link
Member

suztomo commented Apr 11, 2024

If you use Docker container, doesn't WORKDIR (https://docs.docker.com/reference/dockerfile/#workdir) solve your problem?

@suztomo suztomo added type: question Request for information or clarification. Not an issue. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 11, 2024
@loicmathieu
Copy link
Author

I don't understand, I'm using the Batch Java SDK not the Docker SDK.
There is not way to set the working directory via the Batch Java SDK, this is why I opened this issue.

@suztomo
Copy link
Member

suztomo commented Apr 11, 2024

(Re-reading your comments) Am I right this is randomness is the reason why Dockerfile's WORKDIR does not work for your case?

We mount a volume in the batch job, this volume is created from a bucket where we create a random folder for each Job. We use this random folder as the mount path so we would like to set the working directory of the Job to the mount path as we upload files in the bucket before launching the job so it would be more convenient.

@loicmathieu
Copy link
Author

We run arbitrary Docker images that the user can supply so we cannot rely on the Dockerfile's WORKDIR, and even if we could, we create a random directory (we should be able to overcome this but the first reason will still stood).

@loicmathieu
Copy link
Author

For the record, CloudRun allow setting a working directory from the SDK when creating a container

@suztomo
Copy link
Member

suztomo commented Apr 19, 2024

Can I get the URL you read for Cloud Run's case?

@loicmathieu
Copy link
Author

@suztomo
Copy link
Member

suztomo commented Apr 19, 2024

Thank you for the reference. I explored the API definition but didn't find similar properties in the Batch API (https://cloud.google.com/batch/docs/reference/rest/v1/projects.locations.jobs#Job). Unfortunately this problem cannot be solved by Java SDK (this repository). Would you sent the feature request of setting the working directory through https://cloud.google.com/batch/docs/get-started#get-support?

To provide any feedback or feature requests for Batch, ... For all other feedback about Batch, select "Product feedback."

@loicmathieu
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants