Skip to content

added a memory string parser - #197

Closed
ericmjl wants to merge 5 commits into
dask:masterfrom
ericmjl:parse-memory
Closed

ericmjl wants to merge 5 commits into
dask:masterfrom
ericmjl:parse-memory

Conversation

@ericmjl

@ericmjl ericmjl commented Nov 16, 2018 •

Copy link
Copy Markdown
Contributor

cc: @jhamman, @sntgluca, @guillaumeeb

I am proceeding with very small steps with this PR. This PR is a very focused one, and only adds a memory string parser, such that an end-user can specify the amount of RAM that they would like per worker node.

I have done the following:

  • Added a memory string parser
  • Updated the docstring to state that memory is a kwarg that can be specified in lieu of the resource string.

If I remember correctly, I can use multiple lines to specify resources. Hence:

#$ -l m_mem_free=8G
#$ -l h_rt=1500000

should be equivalent to:

#$ -l m_mem_free=8G,h_rt=1500000

@sntgluca, can you confirm/disprove my memory on this?

Still wondering about the following:

  • Should I add a test for the memory string parser? If so, where is the best place to put it?
  • Should I append to the example shown in the SGECluster docstring?

If merged, then this PR resolves in part #195, but not fully.

@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.

Thanks @ericmjl!

A few comments, have a look at distributed.utils for memory string conversion.

Comment thread dask_jobqueue/sge.py Outdated
Destination queue for each worker job. Passed to `#$ -q` option.
memory: str
The amount of memory requested per worker job. Passed to `#$ -l` option. Can be
specified in lieu of `resource_spec`.

@guillaumeeb guillaumeeb Nov 17, 2018 •

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.

Not sure you should override default docstring here. The addition you make should be implicit, even if it is not the case currently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok! Will take this out.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@guillaumeeb, actually, I think the default docstring should be overridden, so as to make clear what memory is being specified.

As I learned today, there are multiple memory specification possibilities for grid engine. Two that I currently know of are m_mem_free and h_vmem. In this PR, I am forcing the memory keyword argument to be passed into m_mem_free, and I think this should be made explicit for SGECluster users.

As far as I can tell, m_mem_free is the most commonly used option for memory specification in job scripts here at work. h_vem is less commonly used. I expect that m_mem_free should be the correct default option for 95% of SGECluster use cases.

The Zen of Python states that "explicit is better than implicit", and I think it'd be better to state explicitly in the docstring that memory is passed to #$ -l m_mem_free, so that the end-user knows that if they need to specify h_vmem instead/on top the requested worker RAM, they still can do so with the resource_spec keyword argument as well.

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'm just not sure of what will append to the consolidated docstring, as memory is already defined in JobQueueCluster class in core.py:

    memory: str
        Total amount of memory per job

You may end up with two different memory entries in the docstring. This is worth testing, or maybe look at docrep module to see if it provide some tools for this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Understood. Thank you for pointing that out! I will ensure that the docs are clear and unambiguous on this pointer.

Comment thread dask_jobqueue/sge.py Outdated

# Define resource specifications. There are only two cases allowed in this
# implementation: either specify using resource_spec, or specify using the rest of the
# kwargs.

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.

@lesteve would say that this comment is useless, the code is explicit :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removing!

Comment thread dask_jobqueue/sge.py
if resource_spec is not None:
header_lines.append('#$ -l %(resource_spec)s')
else:
header_lines.append('#$ -l m_mem_free=%s' % parse_memory(kwargs.get('memory')))

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'm wondering if you could add CPU resources spec too, even if this is not the original problem, shouldn't be too hard or introduce much noise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd like to hold off on that, but only for this PR. Happy to do it in a separate PR, so that we can settle issues independently.

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.

Ok, fine by me.

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.

m_mem_free does not exist on my SGE cluster. Quickly googling this may only exist for Univa Grid Engine.
On my cluster there is mem_req that could be used. Does that exist on yours @ericmjl?

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.

It does not look like mem_req is standard at all ... not sure what to do.

@ericmjl ericmjl Nov 27, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lesteve I am starting to discover this as well. It appears that mapping the memory keyword argument to any particular configuration string is not going to be productive.

I am beginning to think I should close this PR and open a new PR with the following changes:

  1. Notification to end-user that the memory kwarg is not mappable to memory configuration, because the grid engine system is too flexible in this regard.
  2. Documentation fix that states clearly that an end-user needs to know how memory requirements are specified per job.

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.

Wow, that's good to know! It there is no memory option standard, then yes, no other choice to keep with resources_spec and document this.

Comment thread dask_jobqueue/sge.py
logger.debug("Job script: \n %s" % self.job_script())


def parse_memory(memory: str):

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 think the input to this fonction should be worker_memory, that we optain using distributed.utils.parse_bytes. Memory kwarg can be a number with no explicit unit if I'm not mistaken. You should probably use format_memory from the same package, and base your conversation from its output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@guillaumeeb I did a search of dask/distributed for format_memory, but could not find it. Here's the URL to the search: https://github.com/dask/distributed/search?utf8=✓&q=format_memory&type=

Can you point to where the function format_memory is located?

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @mrocklin! Just to confirm, then, @guillaumeeb, you were referring to parse_bytes when you wrote format_memory? Having found parse_bytes, I think I know how to move forward from here.

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've got format_bytes just above, sorry the function name I used was wrong: https://github.com/dask/distributed/blob/964a917c45e8c11b16086cf05949d3529cc0986a/distributed/utils.py#L1081-L1107.

The only thing is that format_bytes uses "real" Giga/Mega/Kilobytes and note Gibi/Mebi/Kibibytes (see https://en.wikipedia.org/wiki/Gibibyte). For example, PBS uses the GB term, but its meaning is GiB. See https://github.com/dask/dask-jobqueue/blob/master/dask_jobqueue/pbs.py#L106-L128. But I actually don't really like this part of the code, and since GiB>GB, I think it's fine to use Dask's GB as GiB for PBS/SGE, without doing a real conversion.

@guillaumeeb

Copy link
Copy Markdown
Member

As for your questions, it would definitly be valuable to have a test, at least checking that the job_script contains the correct resource_spec even without specifying it.

For the docstring as you wish, this does not look mandatory to me.

@guillaumeeb

Copy link
Copy Markdown
Member

Broken CI seems unrelated to your PR, see #201.

@guillaumeeb

Copy link
Copy Markdown
Member

CI problem is corrected on master, you can merge it to have correct Travis inputs.

@ericmjl

ericmjl commented Nov 26, 2018

Copy link
Copy Markdown
Contributor Author

@guillaumeeb, it appears that my use of mypy-style type annotations is breaking tests. Happy to remove it, though can I just check, is mypy being used in dask-jobqueue?

@guillaumeeb

Copy link
Copy Markdown
Member

is mypy being used in dask-jobqueue?

Nope, never used it. From what I've seen in Dask related projects, we usually just use docstrings to precise args type, or don't precise it at all.

@guillaumeeb

Copy link
Copy Markdown
Member

@ericmjl OK to close in favor of #220?

@ericmjl

ericmjl commented Jan 16, 2019

Copy link
Copy Markdown
Contributor Author

@guillaumeeb yes, closing right now!

@ericmjl ericmjl closed this Jan 16, 2019
@ericmjl
ericmjl deleted the parse-memory branch January 16, 2019 16:11
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.

4 participants