-
Notifications
You must be signed in to change notification settings - Fork 4
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
Accommodate Nextflow CPU/Memory in Nomad Job taskResources #27
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8a702a1
resolve merge conflict [ci skip]
abhi18av c7a6ec1
resolve merge conflict [ci skip]
abhi18av 6351317
accommodate task cpus and memory directives [ci skip]
abhi18av ddc7bd3
enable all tests [ci skip]
abhi18av 660f8c8
refactor to accommodate Jorge's feedback and disable mock server test…
abhi18av 09a980a
setup defaults [ci skip]
abhi18av File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.0.2 | ||
version=0.0.3-rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,9 @@ package nextflow.nomad.executor | |
|
||
import groovy.json.JsonOutput | ||
import groovy.json.JsonSlurper | ||
import io.nomadproject.client.models.Resources | ||
import nextflow.nomad.NomadConfig | ||
import nextflow.util.MemoryUnit | ||
import okhttp3.mockwebserver.MockResponse | ||
import okhttp3.mockwebserver.MockWebServer | ||
import spock.lang.Specification | ||
|
@@ -58,13 +60,14 @@ class NomadServiceSpec extends Specification{ | |
List<String> args = ["theCommand", "theArgs"] | ||
String workingDir = "theWorkingDir" | ||
Map<String, String>env = [test:"test"] | ||
Resources resources = new Resources().cores(1).memoryMB(1000) | ||
|
||
mockWebServer.enqueue(new MockResponse() | ||
.setBody(JsonOutput.toJson(["EvalID":"test"]).toString()) | ||
.addHeader("Content-Type", "application/json")); | ||
when: | ||
|
||
def idJob = service.submitTask(id, name, image, args, workingDir,env) | ||
def idJob = service.submitTask(id, name, image, args, workingDir,env,resources) | ||
def recordedRequest = mockWebServer.takeRequest(); | ||
def body = new JsonSlurper().parseText(recordedRequest.body.readUtf8()) | ||
|
||
|
@@ -85,6 +88,8 @@ class NomadServiceSpec extends Specification{ | |
body.Job.TaskGroups[0].Name == "group" | ||
body.Job.TaskGroups[0].Tasks.size() == 1 | ||
body.Job.TaskGroups[0].Tasks[0].Name == "nf-task" | ||
body.Job.TaskGroups[0].Tasks[0].Resources.Cores == 1 | ||
body.Job.TaskGroups[0].Tasks[0].Resources.MemoryMB == 1000 | ||
body.Job.TaskGroups[0].Tasks[0].Driver == "docker" | ||
body.Job.TaskGroups[0].Tasks[0].Config.image == image | ||
body.Job.TaskGroups[0].Tasks[0].Config.work_dir == workingDir | ||
|
@@ -94,60 +99,6 @@ class NomadServiceSpec extends Specification{ | |
!body.Job.TaskGroups[0].Tasks[0].Config.mount | ||
} | ||
|
||
void "submit a task with docker volume"(){ | ||
given: | ||
def config = new NomadConfig( | ||
client:[ | ||
address : "http://${mockWebServer.hostName}:${mockWebServer.port}" | ||
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've removed this test as we decided not to continue with |
||
], | ||
jobs:[ | ||
dockerVolume:'test' | ||
] | ||
) | ||
def service = new NomadService(config) | ||
|
||
String id = "theId" | ||
String name = "theName" | ||
String image = "theImage" | ||
List<String> args = ["theCommand", "theArgs"] | ||
String workingDir = "a/b/c" | ||
Map<String, String>env = [test:"test"] | ||
|
||
mockWebServer.enqueue(new MockResponse() | ||
.setBody(JsonOutput.toJson(["EvalID":"test"]).toString()) | ||
.addHeader("Content-Type", "application/json")); | ||
when: | ||
|
||
def idJob = service.submitTask(id, name, image, args, workingDir,env) | ||
def recordedRequest = mockWebServer.takeRequest(); | ||
def body = new JsonSlurper().parseText(recordedRequest.body.readUtf8()) | ||
|
||
then: | ||
idJob | ||
|
||
and: | ||
recordedRequest.method == "POST" | ||
recordedRequest.path == "/v1/jobs" | ||
|
||
and: | ||
body.Job | ||
body.Job.ID == id | ||
body.Job.Name == name | ||
body.Job.Datacenters == [] | ||
body.Job.Type == "batch" | ||
body.Job.TaskGroups.size() == 1 | ||
body.Job.TaskGroups[0].Name == "group" | ||
body.Job.TaskGroups[0].Tasks.size() == 1 | ||
body.Job.TaskGroups[0].Tasks[0].Name == "nf-task" | ||
body.Job.TaskGroups[0].Tasks[0].Driver == "docker" | ||
body.Job.TaskGroups[0].Tasks[0].Config.image == image | ||
body.Job.TaskGroups[0].Tasks[0].Config.work_dir == workingDir | ||
body.Job.TaskGroups[0].Tasks[0].Config.command == args[0] | ||
body.Job.TaskGroups[0].Tasks[0].Config.args == args.drop(1) | ||
|
||
body.Job.TaskGroups[0].Tasks[0].Config.mount == [type:"volume", target:"a", source:"test", readonly:false] | ||
} | ||
|
||
void "should check the state"(){ | ||
given: | ||
def config = new NomadConfig( | ||
|
@@ -208,13 +159,14 @@ class NomadServiceSpec extends Specification{ | |
List<String> args = ["theCommand", "theArgs"] | ||
String workingDir = "a/b/c" | ||
Map<String, String>env = [test:"test"] | ||
Resources resources = new Resources().cores(1).memoryMB(1000) | ||
|
||
mockWebServer.enqueue(new MockResponse() | ||
.setBody(JsonOutput.toJson(["EvalID":"test"]).toString()) | ||
.addHeader("Content-Type", "application/json")); | ||
when: | ||
|
||
def idJob = service.submitTask(id, name, image, args, workingDir,env) | ||
def idJob = service.submitTask(id, name, image, args, workingDir,env,resources ) | ||
def recordedRequest = mockWebServer.takeRequest(); | ||
def body = new JsonSlurper().parseText(recordedRequest.body.readUtf8()) | ||
|
||
|
@@ -253,7 +205,7 @@ class NomadServiceSpec extends Specification{ | |
def config = new NomadConfig( | ||
client:[ | ||
address : "http://${mockWebServer.hostName}:${mockWebServer.port}", | ||
token: "1234" | ||
token: "123456789012345678901234567" | ||
], | ||
jobs:[ | ||
dockerVolume:'test' | ||
|
@@ -267,13 +219,14 @@ class NomadServiceSpec extends Specification{ | |
List<String> args = ["theCommand", "theArgs"] | ||
String workingDir = "a/b/c" | ||
Map<String, String>env = [test:"test"] | ||
Resources resources = new Resources().cores(1).memoryMB(1000) | ||
|
||
mockWebServer.enqueue(new MockResponse() | ||
.setBody(JsonOutput.toJson(["EvalID":"test"]).toString()) | ||
.addHeader("Content-Type", "application/json")); | ||
when: | ||
|
||
def idJob = service.submitTask(id, name, image, args, workingDir,env) | ||
def idJob = service.submitTask(id, name, image, args, workingDir,env, resources ) | ||
def recordedRequest = mockWebServer.takeRequest(); | ||
def body = new JsonSlurper().parseText(recordedRequest.body.readUtf8()) | ||
|
||
|
@@ -283,6 +236,6 @@ class NomadServiceSpec extends Specification{ | |
and: | ||
recordedRequest.method == "POST" | ||
recordedRequest.path == "/v1/jobs" | ||
recordedRequest.headers.values('X-Nomad-Token').first()=='1234' | ||
recordedRequest.headers.values('X-Nomad-Token').first()=='123456789012345678901234567' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
don't like to expose specific nomad objects outside of the service
I mean, Resources is something strong related with the Service but not with the Task. Maybe we can use some TaskResource class as parameter and let the Service do the conversion to a nomad Resource object
it sounds a little more complicated/elaborated but in this way we have separate both concepts (nextflow vs nomad)
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.
Hi @jagedn , okay so I've tried to refactor the code keeping different layers separate. Let me know what you think about the current structure?
I do think that we can explore the idea regarding a specific "translation" class which covers all aspects of
NomadJobDefinition
from aNextflowTask
, however I suggest that we still continue the current iterations and revisit this once the plugin has stabilised in its design - what do you think?