-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add units to argument names in ray.init and ray.wait. #3666
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
…y -> object_store_memory_bytes, timeout -> timeout_seconds.
|
Following up on comments from #3629. @ericl I agree megabytes are more intuitive here, but I felt that @atumanov Consistency with SI unit prefixes is an interesting idea, I guess that means using |
|
@robertnishihara I believe memory_mb is common terminology, imo the gains of removing six zeros is worth it even if it wasn't... |
|
https://docs.oracle.com/database/nosql-12.1.3.1/AdminGuide/independent_commands.html E.g., oracle cli uses memory_mb |
|
@robertnishihara , actually, it would be |
|
something like this : |
|
Test FAILed. |
| INFINITE_RECONSTRUCTION = 2**30 | ||
|
|
||
| # Max bytes to allocate to plasma unless overriden by the user | ||
| DEFAULT_MAX_MEMORY_MB = 20 * 1000 |
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.
moved to this file from services.py
|
Thanks @ericl @atumanov Let's give I really dislike the "humanfriendly" approach. It's more difficult to work with programmatically and it's so confusing that I always have to check the documentation or other examples every time I use it (e.g., for docker, is it |
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
|
python/ray/services.py
Outdated
| # Compare the requested memory size to the memory available in | ||
| # /dev/shm. | ||
| if shm_avail > object_store_memory: | ||
| if shm_avail > object_store_memory_mb: |
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.
are you comparing bytes to megabytes 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.
Thanks a lot! that was a bug!
| # Print the object store memory using two decimal places. | ||
| object_store_memory_str = (object_store_memory / 10**7) / 10**2 | ||
| logger.info("Starting the Plasma object store with {} GB memory " | ||
| object_store_memory_str = (object_store_memory_mb // 10) / 10**2 |
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.
this is a great place where a library could "pretty-print" the object store memory for you into a human readable format.
| raise DeprecationWarning("The use_raylet argument is deprecated. " | ||
| "Please remove it.") | ||
|
|
||
| if object_store_memory is not None: |
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.
object_store_memory_mb ?
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.
This is intentional. It is used to print a deprecation warning.
| "deprecated. Please use 'object_store_memory_mb'.") | ||
| object_store_memory_mb = object_store_memory / 10**6 | ||
|
|
||
| if redis_max_memory is not None: |
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.
redis_max_memory_mb ?
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.
This is intentional. It is used to print a deprecation warning.
| def wait(object_ids, | ||
| num_returns=1, | ||
| timeout_seconds=None, | ||
| timeout=None, |
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 see you're trying to make it backward compatible. However, what I'm worried about is existing applications using positional arguments instead of keyword arguments. This change will break them, unfortunately, due to the mismatch of time units between timeout and timeout_seconds! I propose explicitly deprecating the previous interface. See below.
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 could consider using @deprecated on the old interface, and make it call the new interface. What I'm worried about here is that the current approach is changing the API twice, once to add timeout_seconds and again to remove timeout. This is a noop for keyword argument users, but is a breaking change for positional argument users. Why not:
@deprecated(version='0.6.2', reason='timeout deprecated in favor of timeout_seconds')
def ray.wait(object_ids, num_returns=1, timeout=None, worker=global_worker):
return ray.wait(object_ids = object_ids,
num_returns = num_returns,
timeout_seconds = timeout,
global_worker = global_worker)
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.
Hopefully that won't happen much, since using positional arguments for keyword arguments is a bad practice.
That said, I'm not sure I understand your suggestion as Python functions can't be overloaded.
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.
That said, I am ok with immediately invalidating the old API instead of trying to do it gracefully.
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.
sorry, I meant something like ray.future.wait(object_ids, num_returns, timeout_seconds, global_worker).
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 see, thanks. I prefer to update the ray.wait API right away.
src/ray/raylet/node_manager.cc
Outdated
| << "by the redis LRU configuration. Consider increasing the memory " | ||
| "allocation via " | ||
| << "ray.init(redis_max_memory=<max_memory_bytes>)."; | ||
| << "ray.init(redis_max_memory_mb=<max_memory_bytes>)."; |
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.
nit: =<max_memory_megabytes>
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.
thanks, fixed
test/actor_test.py
Outdated
| for _ in range(num_objects): | ||
| obj = a.create_object.remote(object_store_memory // num_objects) | ||
| obj = a.create_object.remote( | ||
| 10**6 * object_store_memory_mb // num_objects) |
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.
minor: This is correct, but I would put parens around (10**6 * object_store_memory_mb) to ensure/express correct/desired order of operations.
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.
fixed
|
Thanks @atumanov, I understand your proposal, however I still think the "human-readable" approach is too difficult to use. |
|
Test FAILed. |
|
Jenkins, retest this please. |
|
Test PASSed. |
|
Timeouts are in seconds everywhere in python, and the argument is called For the transition I suggest the following: Till 1.0, give a deprecation warning if |
atumanov
left a comment
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.
|
|
||
|
|
||
| def wait(object_ids, num_returns=1, timeout=None, worker=None): | ||
| def wait(object_ids, num_returns=1, timeout_seconds=None, worker=None): |
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've agreed offline that this will go back to timeout in #3706 . Note that this will preserve the API, but will change the semantics (units) for the timeout parameter in the 0.6.2 release.
| if object_store_memory > MAX_DEFAULT_MEM: | ||
| if object_store_memory_mb > ray.ray_constants.DEFAULT_MAX_MEMORY_MB: | ||
| logger.warning( | ||
| "Warning: Capping object memory store to {}GB. ".format( |
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.
nit: "capping object memory store" --> "capping object store memory"
|
|
||
| # Do some sanity checks. | ||
| if object_store_memory > system_memory: | ||
| if object_store_memory_mb > system_memory_mb: |
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.
nit: I would make this sanity check immediately after if plasma_directory is None
line: https://github.com/ray-project/ray/pull/3666/files#diff-54ac27010a06993004bec4677c7e583eR1048
| cleanup=True, | ||
| resources={"CPU": 1}, | ||
| object_store_memory=100 * (2**20) # 100 MB | ||
| object_store_memory_mb=100 # 100 MB |
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 might want to document somewhere that we interpret MB as 10e6, not 2^20
|
Closing for now due to #3706. |
This replaces #3629.
This makes the following changes:
object_store_memory->object_store_memory_bytesredis_max_memory->redis_max_memory_bytestimeout->timeout_millisecondsAddresses #3411.