Skip to content

Commit

Permalink
Automatic style fix for droidlet
Browse files Browse the repository at this point in the history
  • Loading branch information
bot committed Feb 1, 2023
1 parent ab68f40 commit 2f07e38
Show file tree
Hide file tree
Showing 61 changed files with 55 additions and 69 deletions.
1 change: 1 addition & 0 deletions droidlet/dialog/post_process_logical_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import copy


# move location inside reference_object for Fill and Destroy actions
def fix_fill_and_destroy_location(action_dict):
action_name = action_dict["action_type"]
Expand Down
1 change: 1 addition & 0 deletions droidlet/interpreter/craftassist/block_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random
import Levenshtein


# TODO FILTERS!
def get_block_type(s, block_data_info, color_bid_map) -> Tuple:
"""string -> (id, meta)
Expand Down
4 changes: 2 additions & 2 deletions droidlet/interpreter/craftassist/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def step(self):
# replace blocks if possible
R = self.replace.copy()
self.replace.clear()
for (pos, idm) in R:
for pos, idm in R:
agent.set_held_item(idm)
if agent.place_block(*pos):
logging.debug("Move: replaced {}".format((pos, idm)))
Expand Down Expand Up @@ -254,7 +254,7 @@ def handle_no_path(self, agent):
x, y, z = newpos
newpos_blocks = agent.get_blocks(x, x, y, y + 1, z, z)
# dig if necessary
for (bp, idm) in npy_to_blocks_list(newpos_blocks, newpos):
for bp, idm in npy_to_blocks_list(newpos_blocks, newpos):
self.replace.add((bp, idm))
agent.dig(*bp)
# move
Expand Down
1 change: 1 addition & 0 deletions droidlet/interpreter/interpret_comparators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from droidlet.memory.memory_values import FilterValue
from droidlet.memory.memory_attributes import ComparatorAttribute


# TODO distance between
# TODO make this more modular. what if we want to redefine just distance_between in a new agent?
def interpret_comparator(interpreter, speaker, d, is_condition=True):
Expand Down
1 change: 0 additions & 1 deletion droidlet/interpreter/interpret_reference_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ def interpret_reference_object(
_, clarification_task_mems = interpreter.memory.basic_search(clarification_query)
# does a clarification task referencing this interpreter exist?
if not clarification_task_mems:

mems = maybe_get_text_span_mems(interpreter, speaker, d)
if mems:
update_attended_and_link_lf(interpreter, mems)
Expand Down
1 change: 1 addition & 0 deletions droidlet/interpreter/robot/default_behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def init_logger():

init_logger()


# TODO: Move these utils to a suitable place - as a class method in TripleNode
def add_or_replace(agent, pred_text, obj_text):
memids, _ = agent.memory.basic_search(f"SELECT uuid FROM Triple WHERE pred_text={pred_text}")
Expand Down
2 changes: 2 additions & 0 deletions droidlet/interpreter/robot/task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Copyright (c) Facebook, Inc. and its affiliates.
"""


# put a counter and a max_count so can't get stuck?
class Task(object):
def __init__(self, featurizer=None):
Expand Down
1 change: 1 addition & 0 deletions droidlet/interpreter/robot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ def step(self):
# Get a list of current detections
objects = DetectedObjectNode.get_all(self.agent.memory)
pos = self.agent.mover.get_base_pos_in_canonical_coords()

# pick all from unexamined, in-sight object
def pick_random_in_sight(objects, base_pos):
for x in objects:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def record_video(image_filenames, image_timestamps, video_filename, fps=30, real
out = cv2.VideoWriter(video_filename, cv2.VideoWriter_fourcc(*"mp4v"), fps, size)
if realtime:
prev_timestamp = 0
for (timestamp, image) in zip(image_timestamps, images):
for timestamp, image in zip(image_timestamps, images):
frame_repeats = round((timestamp - prev_timestamp) * fps)
for _ in range(frame_repeats):
out.write(image)
Expand Down
1 change: 0 additions & 1 deletion droidlet/lowlevel/hello_robot/remote/remote_hello_saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def return_paths(self, id_):
return img_folder, img_folder_dbg, depth_folder, lidar_folder, data_file

def create_dirs(self, id_):

img_folder, img_folder_dbg, depth_folder, lidar_folder, data_file = self.return_paths(id_)

for x in [img_folder, img_folder_dbg, depth_folder, lidar_folder]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def stop(self):
return result

def background_loop(self):

rospy.Subscriber(
"/stretch/joint_states", JointState, self._joint_states_callback, queue_size=1
)
Expand Down
1 change: 0 additions & 1 deletion droidlet/lowlevel/hello_robot/remote/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def is_obstacle_ahead(dist, depth_fn):

# Check if a significantly large obstacle is present and filter out smaller noisy regions
if np.sum(mask) / 255.0 > 0.01 * mask.shape[0] * mask.shape[1]:

image_gray = cv2.cvtColor(cv2.bitwise_and(rgb, rgb, mask=mask), cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(image_gray, 100, 200)
edges = cv2.dilate(edges, None)
Expand Down
1 change: 0 additions & 1 deletion droidlet/lowlevel/locobot/remote/policy/utils/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def forward(self, x):
# https://github.com/ikostrikov/pytorch-a2c-ppo-acktr-gail/blob/master/a2c_ppo_acktr/model.py#L82
class NNBase(nn.Module):
def __init__(self, recurrent, recurrent_input_size, hidden_size):

super(NNBase, self).__init__()
self._hidden_size = hidden_size
self._recurrent = recurrent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class LocalActionServer(object):
"""docstring for LocalActionServer"""

def __init__(self):

self._lock = threading.RLock()
self._state = LocalActionStatus.UNKOWN

Expand Down
1 change: 0 additions & 1 deletion droidlet/lowlevel/minecraft/pyworld/run_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def block_generator(world):


if __name__ == "__main__":

ticker = Ticker(tick_rate=0.01, step_rate=0.2, ip="localhost", port=6002)
ticker_thread = Thread(target=ticker.start, args=())
ticker_thread.start()
Expand Down
2 changes: 1 addition & 1 deletion droidlet/lowlevel/minecraft/pyworld/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def blocks_to_dict(self):
def get_idm_at_locs(self, xyzs: Sequence[XYZ]) -> Dict[XYZ, IDM]:
"""Return the ground truth block state"""
d = {}
for (x, y, z) in xyzs:
for x, y, z in xyzs:
B = self.get_blocks(x, x, y, y, z, z)
d[(x, y, z)] = tuple(B[0, 0, 0, :])
return d
Expand Down
1 change: 0 additions & 1 deletion droidlet/lowlevel/minecraft/small_scenes_with_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ def build_shape_scene(args):
fence = getattr(args, "fence", False)
blocks = build_base_world(args.SL, args.H, args.GROUND_DEPTH, fence=fence)
if args.iglu_scenes:

with open(args.iglu_scenes, "rb") as f:
assets = pickle.load(f)
sid = np.random.choice(list(assets.keys()))
Expand Down
1 change: 0 additions & 1 deletion droidlet/lowlevel/test/test_transforms3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ def test_open3d_pcd_transform(self):


if __name__ == "__main__":

unittest.main()
1 change: 1 addition & 0 deletions droidlet/memory/craftassist/mc_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from droidlet.memory.memory_filters import Attribute


# TODO sqlize these?
# FIXME!!!!! rn this will not accurately count voxels in
# InstSeg objects with given properties;
Expand Down
4 changes: 2 additions & 2 deletions droidlet/memory/craftassist/mc_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def update(self, perception_output: namedtuple = None, areas_to_perceive: List =

# 5. Update the state of the world when a block is changed.
if perception_output.changed_block_attributes:
for (xyz, idm) in perception_output.changed_block_attributes:
for xyz, idm in perception_output.changed_block_attributes:
# 5.1 Update old instance segmentation if needed
self.maybe_remove_inst_seg(xyz)

Expand Down Expand Up @@ -642,7 +642,7 @@ def _load_mob_types(self, mobs, mob_property_data, load_mob_types=True):
return

mob_name_to_properties = mob_property_data.get("name_to_properties", {})
for (name, m) in mobs.items():
for name, m in mobs.items():
type_name = "spawn " + name

# load single mob as schematics
Expand Down
2 changes: 1 addition & 1 deletion droidlet/memory/craftassist/mc_memory_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def create(cls, memory, blocks: Sequence[Block]) -> str:
>>> create(memory, blocks)
"""
memid = cls.new(memory)
for ((x, y, z), (b, m)) in blocks:
for (x, y, z), (b, m) in blocks:
memory.db_write(
"""
INSERT INTO Schematics(uuid, x, y, z, bid, meta)
Expand Down
1 change: 1 addition & 0 deletions droidlet/memory/memory_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
### in various filter interpreters
####################################################################################


# attribute has function signature list(mems) --> list(value)
class Attribute:
def __init__(self, memory):
Expand Down
2 changes: 1 addition & 1 deletion droidlet/memory/place_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def sync_traversible(self, locs, h=0):
# overwrite traversibility map from slam service
self.maps[h]["map"][:] = 0
self.maps[h]["updated"][:] = self.get_time()
for (x, z) in locs:
for x, z in locs:
i, j = self.real2map(x, z, h)
s = max(i - self.map_size + 1, j - self.map_size + 1, -i, -j)
if s > 0:
Expand Down
2 changes: 1 addition & 1 deletion droidlet/perception/craftassist/low_level_perception.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def perceive(self, force=False):
)
# Changed blocks and their attributes
perceive_info["changed_block_attributes"] = {}
for (xyz, idm) in self.agent.safe_get_changed_blocks():
for xyz, idm in self.agent.safe_get_changed_blocks():
interesting, player_placed, agent_placed = self.on_block_changed(
xyz, idm, boring_blocks
)
Expand Down
3 changes: 2 additions & 1 deletion droidlet/perception/craftassist/shape_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def moment_at_center(npy, sl):
## THICKEN
#############################################


# this doesn't preserve corners. should it?
# separate deltas per dim?
def thicker_blocks(blocks, delta=1):
Expand Down Expand Up @@ -198,7 +199,7 @@ def scale_sparse(blocks, lams=(1.0, 1.0, 1.0)):
cell_szs = szs / big_szs
big_szs = big_szs.astype("int32")
big = np.zeros(tuple(big_szs) + (2,)).astype("int32")
for (x, y, z) in inp_dict.keys():
for x, y, z in inp_dict.keys():
for i in range(flint(x * lams[0]), ceint(x * lams[0]) + 2):
for j in range(flint(y * lams[1]), ceint(y * lams[1]) + 2):
for k in range(flint(z * lams[2]), ceint(z * lams[2]) + 2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def get_in_coco_format(self, idx):


def make_coco_transforms(image_set):

normalize = T.Compose(
[T.ToTensor(), T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def get_height_and_width(self, idx):


def make_coco_panoptic_transforms(image_set):

normalize = T.Compose(
[
T.ToTensor(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def pad_to_sidelength(schematic, labels=None, nothing_id=0, sidelength=32):

# TODO cut outliers


# TODO simplify
def fit_in_sidelength(schematic, labels=None, nothing_id=0, sl=32, max_shift=0):
schematic, labels = pad_to_sidelength(
Expand All @@ -104,7 +105,6 @@ def fit_in_sidelength(schematic, labels=None, nothing_id=0, sl=32, max_shift=0):


def make_example_from_raw(schematic, labels=None, augment={}, nothing_id=0, sl=32):

max_shift = augment.get("max_shift", 0)
s, l, o = fit_in_sidelength(
schematic, labels=labels, nothing_id=nothing_id, max_shift=max_shift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ def get_in_coco_format(self, idx):


def make_lvis_transforms(image_set):

normalize = T.Compose(
[T.ToTensor(), T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def get_in_coco_format(self, idx: int):


def make_voc_transforms(image_set, remove_difficult):

normalize = T.Compose(
[T.ToTensor(), T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def fit_in_sidelength(schematic, labels=None, nothing_id=0, sl=32, max_shift=0):


def make_example_from_raw(schematic, labels=None, augment={}, nothing_id=0, sl=32):

max_shift = augment.get("max_shift", 0)
s, l, o = fit_in_sidelength(
schematic, labels=labels, nothing_id=nothing_id, max_shift=max_shift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def pad_to_sidelength(schematic, labels=None, nothing_id=0, sidelength=32):

# TODO cut outliers


# TODO simplify
def fit_in_sidelength(schematic, labels=None, nothing_id=0, sl=32, max_shift=0):
"""Adjust schematics to the center of the padded one"""
Expand Down
1 change: 1 addition & 0 deletions droidlet/perception/robot/handlers/label_propagate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
CAMERA_HEIGHT = 0.6
trans = np.array([0, 0, CAMERA_HEIGHT])


# TODO: Consolidate camera intrinsics and their associated utils across locobot and habitat.
def compute_uvone(height, width):
intrinsic_mat_inv = np.linalg.inv(intrinsic_mat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def get_ground_truth(no_ground_truth, ground_truth_data_dir):
if not no_ground_truth:
if os.path.isdir(ground_truth_data_dir):
gt_data_directory = ground_truth_data_dir + "datasets/"
for (dirpath, dirnames, filenames) in os.walk(gt_data_directory):
for dirpath, dirnames, filenames in os.walk(gt_data_directory):
for f_name in filenames:
file = gt_data_directory + f_name
with open(file) as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_good_ad(template_attributes, flat=False):
if len(r) > 0:
allowed_blocks = template_attributes.get("allowed_blocktypes")
if allowed_blocks:
for (_, btype) in r:
for _, btype in r:
if btype not in allowed_blocks:
new_btype = random.choice(allowed_blocks)
text = text.replace(btype, new_btype)
Expand Down Expand Up @@ -507,7 +507,6 @@ def build_scene(template_attributes, sl=32, flat=False):


if __name__ == "__main__":

template_attributes = {"count": range(1, 5)}
template_attributes["step"] = range(1, 10)
template_attributes["non_shape_names"] = list(SPECIAL_SHAPES_CANONICALIZE.keys())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def substitute_with_spans(action_description_split, d):

if action_dict.get("answer_type", None):
if action_dict["answer_type"] == "TAG" and "tag_name" in action_dict:

# fix for tag values to new
tag_val = action_dict["tag_name"]
if tag_val == "action_reference_object_name":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def _generate_description(self):
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):

# get the text from template object
item = key.generate_description(arg_index=0, index=i, templ_index=j)

Expand Down Expand Up @@ -221,7 +220,6 @@ def _generate_description(self):
for j, templ in enumerate(self.template):
result = []
for i, key in enumerate(templ):

# get the text from template object
item = key.generate_description(arg_index=0, index=i, templ_index=j)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### BLOCKOBJECT TEMPLATES ###
#############################


# TODO: refactor this function.
def define_block_object_type(
template_obj,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update_data(folder):
file called : f_name + "_new.txt" (templated.txt -> templated_new.txt)
"""
f = []
for (dirpath, dirnames, filenames) in walk(folder):
for dirpath, dirnames, filenames in walk(folder):
for f_name in filenames:
if f_name == "templated_modify.txt":
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def update_data(folder):
file called : f_name + "_new.txt" (templated.txt -> templated_new.txt)
"""
f = []
for (dirpath, dirnames, filenames) in walk(folder):
for dirpath, dirnames, filenames in walk(folder):
for f_name in filenames:
if f_name == "templated_modify.txt":
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def update_data(folder):
performs update on the dataset and writes output to a new
file called : f_name + "_new.txt" (templated.txt -> templated_new.txt)
"""
for (dirpath, dirnames, filenames) in walk(folder):
for dirpath, dirnames, filenames in walk(folder):
for f_name in filenames:
action_names = {}
count = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def update_data(folder):
file called : f_name + "_new.txt" (templated.txt -> templated_new.txt)
"""
f = []
for (dirpath, dirnames, filenames) in walk(folder):
for dirpath, dirnames, filenames in walk(folder):
for f_name in filenames:
if f_name == "templated_modify.txt":
continue
Expand Down
Loading

0 comments on commit 2f07e38

Please sign in to comment.