Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 63 additions & 8 deletions .style.yapf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ allow_multiline_dictionary_keys=False
# Allow lambdas to be formatted on more than one line.
allow_multiline_lambdas=False

# Allow splits before the dictionary value.
allow_split_before_dict_value=True

# Number of blank lines surrounding top-level function and class
# definitions.
blank_lines_around_top_level_definition=2

# Insert a blank line before a class-level docstring.
blank_line_before_class_docstring=False

# Insert a blank line before a module docstring.
blank_line_before_module_docstring=False

# Insert a blank line before a 'def' or 'class' immediately nested
# within another 'def' or 'class'. For example:
#
Expand All @@ -42,10 +52,26 @@ blank_line_before_nested_class_or_def=False
# 'key1': 'value1',
# 'key2': 'value2',
# })
coalesce_brackets=True
coalesce_brackets=False

# The column limit.
column_limit=79
column_limit=80

# The style for continuation alignment. Possible values are:
#
# - SPACE: Use spaces for continuation alignment. This is default behavior.
# - FIXED: Use fixed number (CONTINUATION_INDENT_WIDTH) of columns
# (ie: CONTINUATION_INDENT_WIDTH/INDENT_WIDTH tabs) for continuation
# alignment.
# - LESS: Slightly left if cannot vertically align continuation lines with
# indent characters.
# - VALIGN-RIGHT: Vertically align continuation lines with indent
# characters. Slightly right (one more indent character) if cannot
# vertically align continuation lines with indent characters.
#
# For options FIXED, and VALIGN-RIGHT are only available when USE_TABS is
# enabled.
continuation_align_style=SPACE

# Indent width used for line continuations.
continuation_indent_width=4
Expand All @@ -66,7 +92,7 @@ continuation_indent_width=4
# start_ts=now()-timedelta(days=3),
# end_ts=now(),
# ) # <--- this bracket is dedented and on a separate line
dedent_closing_brackets=False
dedent_closing_brackets=True

# Place each dictionary entry onto its own line.
each_dict_entry_on_separate_line=True
Expand All @@ -90,13 +116,13 @@ i18n_function_call=
# 'key2': value1 +
# value2,
# }
indent_dictionary_value=True
indent_dictionary_value=False

# The number of columns to use for indentation.
indent_width=4

# Join short lines into one line. E.g., single line 'if' statements.
join_multiple_lines=True
join_multiple_lines=False

# Do not include spaces around selected binary operators. For example:
#
Expand All @@ -106,7 +132,7 @@ join_multiple_lines=True
#
# 1 + 2*3 - 4/5
#
no_spaces_around_selected_binary_operators=set([])
no_spaces_around_selected_binary_operators={'set()'}

# Use spaces around default or named assigns.
spaces_around_default_or_named_assign=False
Expand All @@ -123,12 +149,16 @@ space_between_ending_comma_and_closing_bracket=True

# Split before arguments if the argument list is terminated by a
# comma.
split_arguments_when_comma_terminated=False
split_arguments_when_comma_terminated=True

# Set to True to prefer splitting before '&', '|' or '^' rather than
# after.
split_before_bitwise_operator=True

# Split before the closing bracket if a list or dict literal doesn't fit on
# a single line.
split_before_closing_bracket=True

# Split before a dictionary or set generator (comp_for). For example, note
# the split before the 'for':
#
Expand All @@ -138,6 +168,10 @@ split_before_bitwise_operator=True
# }
split_before_dict_set_generator=True

# Split after the opening paren which surrounds an expression if it doesn't
# fit on a single line.
split_before_expression_after_opening_paren=True

# If an argument / parameter list is going to be split, then split before
# the first argument.
split_before_first_argument=False
Expand All @@ -149,6 +183,22 @@ split_before_logical_operator=True
# Split named assignments onto individual lines.
split_before_named_assigns=True

# Set to True to split list comprehensions and generators that have
# non-trivial expressions and multiple clauses before each of these
# clauses. For example:
#
# result = [
# a_long_var + 100 for a_long_var in xrange(1000)
# if a_long_var % 10]
#
# would reformat to something like:
#
# result = [
# a_long_var + 100
# for a_long_var in xrange(1000)
# if a_long_var % 10]
split_complex_comprehension=True

# The penalty for splitting right after the opening bracket.
split_penalty_after_opening_bracket=30

Expand All @@ -162,8 +212,12 @@ split_penalty_before_if_expr=0
# operators.
split_penalty_bitwise_operator=300

# The penalty for splitting a list comprehension or generator
# expression.
split_penalty_comprehension=80

# The penalty for characters over the column limit.
split_penalty_excess_character=4500
split_penalty_excess_character=1000

# The penalty incurred by adding a line split to the unwrapped line. The
# more line splits added the higher the penalty.
Expand All @@ -187,3 +241,4 @@ split_penalty_logical_operator=300

# Use the Tab character for indentation.
use_tabs=False

49 changes: 26 additions & 23 deletions .travis/yapf.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
#!/usr/bin/env bash

# Cause the script to exit if a single command fails
set -e

ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)

pushd $ROOT_DIR/../test
find . -name '*.py' -type f -exec yapf --style=pep8 -i -r {} \;
popd

pushd $ROOT_DIR/../python
find . -name '*.py' -type f -not -path './ray/dataframe/*' -not -path './ray/rllib/*' -not -path './ray/cloudpickle/*' -exec yapf --style=pep8 -i -r {} \;
popd

CHANGED_FILES=(`git diff --name-only`)
if [ "$CHANGED_FILES" ]; then
echo 'Reformatted staged files. Please review and stage the changes.'
echo
echo 'Files updated:'
for file in ${CHANGED_FILES[@]}; do
echo " $file"
done
exit 1
else
exit 0
set -eo pipefail

# this stops git rev-parse from failing if we run this from the .git directory
builtin cd "$(dirname "${BASH_SOURCE:-$0}")"

ROOT="$(git rev-parse --show-toplevel)"
builtin cd "$ROOT"

yapf \
--style "$ROOT/.style.yapf" \
--in-place --recursive --parallel \
--exclude 'python/ray/cloudpickle' \
-- \
'test' 'python'

CHANGED_FILES=($(git diff --name-only))

if [[ "${#CHANGED_FILES[@]}" -gt 0 ]]; then
echo 'Reformatted staged files. Please review and stage the changes.'
echo 'Files updated:'

for file in "${CHANGED_FILES[@]}"; do
echo "$file"
done

exit 1
fi
12 changes: 8 additions & 4 deletions python/ray/experimental/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,9 @@ def micros_rel(ts):
parent_times = self._get_times(parent_info)
parent_profile = task_info.get(
task_table[task_id]["TaskSpec"]["ParentTaskID"])

_parent_id = parent_info["worker_id"] + str(micros(min(parent_times)))

parent = {
"cat":
"submit_task",
Expand All @@ -749,8 +752,7 @@ def micros_rel(ts):
"name":
"SubmitTask",
"args": {},
"id": (parent_info["worker_id"] + str(
micros(min(parent_times))))
"id": _parent_id,
}
full_trace.append(parent)

Expand Down Expand Up @@ -808,6 +810,9 @@ def micros_rel(ts):
parent_times = self._get_times(parent_info)
parent_profile = task_info.get(
task_table[task_id]["TaskSpec"]["ParentTaskID"])

_parent_id = parent_info["worker_id"] + str(micros(min(parent_times)))

parent = {
"cat":
"submit_task",
Expand All @@ -824,8 +829,7 @@ def micros_rel(ts):
"name":
"SubmitTask",
"args": {},
"id": (parent_info["worker_id"] + str(
micros(min(parent_times))))
"id": _parent_id,
}
full_trace.append(parent)

Expand Down
6 changes: 4 additions & 2 deletions python/ray/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,13 @@ def run(self):
self.cleanup_task_table()
if len(self.dead_plasma_managers) > 0:
self.cleanup_object_table()

num_plasma_managers = len(self.live_plasma_managers) + len(self.dead_plasma_managers)

log.debug("{} dead local schedulers, {} plasma managers total, {} "
"dead plasma managers".format(
len(self.dead_local_schedulers),
(len(self.live_plasma_managers) + len(
self.dead_plasma_managers)),
num_plasma_managers,
len(self.dead_plasma_managers)))

# Handle messages from the subscription channels.
Expand Down