Skip to content

Add support for job [task] arrays in SGE/UGE - #217

Closed
sntgluca wants to merge 8 commits into
dask:masterfrom
sntgluca:sge_taskarrays
Closed

sntgluca wants to merge 8 commits into
dask:masterfrom
sntgluca:sge_taskarrays

Conversation

@sntgluca

Copy link
Copy Markdown

This is the PoC to implement using job arrays (task arrays) #196
For the moment the implementation is only available for the SGE cluster.

The implementation redefines self._cluster_template to include the 'SGE_TASK_ID' variable and rewrites the start_workers() method in sge.py:SGECluster.
There's a new test test_sge.py:test_taskarrays() to check basic stats on the new function.
I also changed the QUEUE_WAIT time in the tests to allow for more time (my tests required more time).

As a starting strategy, the use of task arrays is determined via a new ta argument in SGECluster:start_workers().

  • If start_workers(ta=True):
    the system checks if it can use task arrays and runs the new function.
  • If start_workers(ta=False) or if task arrays cannot be run:
    it defaults to the original JobQueueCluster:start_workers() function.

The ta argument is True by default, and it's not yet exposed to scale(). Which means, the use of task arrays is automatically activated by default.

@sntgluca

sntgluca commented Jan 13, 2019 •

Copy link
Copy Markdown
Author

The unit test and the CI environment are not integrated.

Currently the test is passed because the SGE_TASK_ID variable, necessary to activate the task array, is not available in the CI environment, and the assertions are skipped.
In this case, the code reverts back to the "normal" start_workers code and a dedicated test is not necessary.

I don't know the environment well enough to fix this. May someone help me?

@guillaumeeb

Copy link
Copy Markdown
Member

ping @lesteve who implemented SGECluster and associated CI.

I will try to look at this PR too.

@guillaumeeb guillaumeeb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So my main point would be to make the change in __init__() if possible. I don't see the need for using a mix of arrays and standard job in one cluster instance (but I may be wrong).

Comment thread dask_jobqueue/sge.py Outdated

logger.debug("Job script: \n %s" % self.job_script())

def start_workers(self, n=1, ta=True):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know this is only a poc on SGE, but I would propose a use_job_arrays, or use_task_arrays at class level. So directly in JobQueueCluster __init__() method in the end.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @guillaumeeb ,
this is a nice suggestion. I can implement the change.
I am working on this in my free time, so I am quite slow to follow up...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure, take your time, I know this situation :)

Comment thread dask_jobqueue/sge.py Outdated
if ta:
logging.debug('Submission using task array')
_original_command_template = self._command_template
self._command_template = self._command_template.replace('${JOB_ID}', '${JOB_ID}.${SGE_TASK_ID}')

@guillaumeeb guillaumeeb Jan 16, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should always have an ID that takes into account potential job arrays or task arrays. the task array part would potentially be empty.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It would be excellent, I am afraid it's difficult to abstract it for all schedulers. I don't remember how job arrays are defined in different schedulers.
Will consider and come up with a suggestion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See how this is done with JOB_ID in PBSCluster currently: https://github.com/dask/dask-jobqueue/blob/master/dask_jobqueue/pbs.py#L98. A simple line in __init__() specific to all Scheduler could be used.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @guillaumeeb ,
thanks for the hint!! I used your approach, and redefined JOB_ID to handle task arrays.
One caveat to note: JOB_ID is the variable name that UGE/SGE uses to define their Job ID. We are kinda breaking the consistency with the scheduler.

In other schedulers, as PBS, the same variable is called PBS_JOBID, hence there's no problem...

I don't see it as a problem, but it's worth to keep it in mind.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep, maybe we would need to change the name at one point.

Comment thread dask_jobqueue/sge.py Outdated

num_jobs = int(math.ceil(n / self.worker_processes))
header_template = self.job_header
self.job_header = header_template + '\n#$ -t 1-{}'.format(num_jobs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes I think that this too should go in __init__()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi, I find this one a bit trickier, since num_jobs is defined when the start_workers function is called.
I could only think of passing num_jobs as

  • a placeholder in the configuration (current solution):
    config = {'num_jobs_placeholder': '%(num_jobs)d'}`
    ...
    self.job_header = self.job_header % {'num_jobs' : num_jobs}
    
  • an environmental variable to be picked up by self.job_header
  • an attribute to substitute in self.job_header

Any other idea?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You're right, no better idea. Just try to avoid as much as possible code duplication.

Comment thread dask_jobqueue/tests/__init__.py Outdated
from __future__ import absolute_import, division, print_function

QUEUE_WAIT = 15 # seconds
QUEUE_WAIT = 120 # seconds

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

120 seconds is a lot of time!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, the scheduler I could test with has longer waiting times...
I run my tests with a longer QUEUE_WAIT, and I forgot to revert to the default value before submitting the pull request.

Should be fixed now.

Comment thread dask_jobqueue/tests/test_sge.py Outdated
""" Starts a small cluster and returns information on jobs and tasks """
cluster.scale(size)
# waiting to allow cluster to start (no pending jobs)
sleep(2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this sleep(2) mandatory?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I need to check if it can be removed.
I added it to give time for the cluster.pending_jobs to be populated.
I was thinking that without it, pending_jobs could be empty because the jobs haven't been scheduled, not because they are running.

Do you have a better suggestion?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@guillaumeeb

Copy link
Copy Markdown
Member

Currently the test is passed because the SGE_TASK_ID variable, necessary to activate the task array, is not available in the CI environment, and the assertions are skipped.

I'm not sure I get it right, you don't have the SGE_TASK_ID variable despite the fact of having launched a job array?

Or maybe your talking about the line

ta = ta and bool(os.getenv('SGE_TASK_ID', None))

I did not see this, but when you call this, you're in the Notebook process, not inside a job. So there is no reason this environment variable is declared, is there?

@sntgluca

sntgluca commented Jan 19, 2019 •

Copy link
Copy Markdown
Author

Hi @guillaumeeb ,

SGE_TASK_ID is not setup in the CI test environment, and I don't know why.

I am confused because I consider SGE_TASK_ID a standard part of the UGE suite. I never came across a cluster without it (I am not sysadmin as you see...).
For instance, it's in the wiki:
http://wiki.gridengine.info/wiki/index.php/Simple-Job-Array-Howto

But in the CI test suite it's undefined.
Therefore the line you refer to above is used to "bypass" the test if the environment (UGE) setup doesn't implement SGE_TASK_ID

IMHO to fix this we should find how to configure the tests to include/allow job arrays.
I am not familiar with your test suite and with UGE setup. I was wondering if someone can help understanding if it can be done, and how.

@guillaumeeb

Copy link
Copy Markdown
Member

SGE_TASK_ID is not setup in the CI test environment, and I don't know why.

I was probably not clear. There is no reason SGE_TASK_ID variable is populated if you're not in an SGE job, is there?

Maybe your talking about a problem you've got later in the test process? In this case, please remove this check so that we can see what is going on!

@sntgluca sntgluca changed the title Added support for using job [task] arrays in SGE/UGE Add support for job [task] arrays in SGE/UGE Jan 26, 2019
@sntgluca

Copy link
Copy Markdown
Author

Hi @lesteve ,

may you take a look at and evaluate this pull request?
In particular, I noticed the SGE environment in the CI isn't setup for using task arrays, making my tests useless...
@guillaumeeb suggested that you would be able to help!

ping @lesteve who implemented SGECluster and associated CI.

I will try to look at this PR too.

Thanks

@lesteve

lesteve commented Jan 30, 2019 •

Copy link
Copy Markdown
Member

Sorry I did not have time to look at this. To sum up, my feeling echoes the feeling of other people in the associated issue (#196): task array support does not seem worth the effort. I will comment on #196 with more complete thoughts.

Sorry if you feel disappointed because you have spent time on this without seeing it get into dask-jobqueue. What I am hoping is that you got more familiar with dask-jobqueue and it will help you for further contributions.

Contributions to dask-jobqueue are very welcome, it seems you are working with @ericmjl so maybe something you could look at is #195, i.e. how to specify the number of CPUs used in resource_spec in SGECluster.

@guillaumeeb

Copy link
Copy Markdown
Member

I'm intentionnaly leaving aside the discussion about the importance of this evolution or not, if it's worth for you then you can try to fix it!

In particular, I noticed the SGE environment in the CI isn't setup for using task arrays, making my tests useless...

For this part, you did not answer my comments: there is no reason for the env variable to be set when you initialize your cluster object or call scale. At this time, you're definitly not in a job.

@sntgluca

sntgluca commented Feb 4, 2019

Copy link
Copy Markdown
Author

@lesteve ,
I understand. I agree supporting task arrays is not a necessary feature. I partially disagree about it's importance ;) based on my experience with HPC. I doubt you'll ever receive many requests for supporting this, as it's going to affect mainly sysadmins and people working closely with them.

I am indeed more comfortable with the package now. I will try to contribute and see where this can lead me :)

@sntgluca

sntgluca commented Feb 4, 2019

Copy link
Copy Markdown
Author

@guillaumeeb,

I initially added a check in SGECluster to be sure that task arrays could be used, and reverted to using normal jobs if SGE_TASK_ID wasn't found.

To answer you question, I removed the checks from the code and from the tests. Waiting to see what happens...

@sntgluca

Copy link
Copy Markdown
Author

Closing this pull request, not in line with current ideas about task array support.

@sntgluca sntgluca closed this May 31, 2020
@sntgluca
sntgluca deleted the sge_taskarrays branch May 31, 2020 08:45
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.

3 participants