Daily arc lint --take BLACK

Differential Revision: D98889675

fbshipit-source-id: e9d0089e5abb73b9327f5453ad20fa5060b12a40
This commit is contained in:
generatedunixname26232875646305581
2026-03-31 03:16:31 -07:00
committed by meta-codesync[bot]
parent 29aecc4b7d
commit bfbed072a0
4 changed files with 30 additions and 30 deletions
+3 -3
View File
@@ -1734,9 +1734,9 @@ class VideoTrackingMultiplexDemo(VideoTrackingDynamicMultiplex):
) )
inference_state["multiplex_state"] = multiplex_state inference_state["multiplex_state"] = multiplex_state
else: else:
assert ( assert self.is_dynamic_model, (
self.is_dynamic_model "New objects are not allowed after state creation"
), "New objects are not allowed after state creation" )
for i in range(num_objects): for i in range(num_objects):
mask_inputs_per_frame[i][frame_idx] = mask_inputs_video_res[i : i + 1] mask_inputs_per_frame[i][frame_idx] = mask_inputs_video_res[i : i + 1]
+3 -3
View File
@@ -142,9 +142,9 @@ class COCO_FROM_JSON:
self.prompts = {} self.prompts = {}
for loc_dict in prompts: for loc_dict in prompts:
self.prompts[int(loc_dict["id"])] = loc_dict["name"] self.prompts[int(loc_dict["id"])] = loc_dict["name"]
assert len(self.prompts) == len( assert len(self.prompts) == len(self._sorted_cat_ids), (
self._sorted_cat_ids "Number of prompts must match number of categories"
), "Number of prompts must match number of categories" )
def getDatapointIds(self): def getDatapointIds(self):
"""Return all datapoint indices for training.""" """Return all datapoint indices for training."""
+21 -21
View File
@@ -209,9 +209,9 @@ class Trainer:
set_seeds(seed_value, self.max_epochs, self.distributed_rank) set_seeds(seed_value, self.max_epochs, self.distributed_rank)
log_env_variables() log_env_variables()
assert ( assert is_dist_avail_and_initialized(), (
is_dist_avail_and_initialized() "Torch distributed needs to be initialized before calling the trainer."
), "Torch distributed needs to be initialized before calling the trainer." )
self._setup_components() # Except Optimizer everything is setup here. self._setup_components() # Except Optimizer everything is setup here.
self._move_to_device() self._move_to_device()
@@ -221,9 +221,9 @@ class Trainer:
self.time_elapsed_meter = DurationMeter("Time Elapsed", self.device, ":.2f") self.time_elapsed_meter = DurationMeter("Time Elapsed", self.device, ":.2f")
if self.checkpoint_conf.resume_from is not None: if self.checkpoint_conf.resume_from is not None:
assert os.path.exists( assert os.path.exists(self.checkpoint_conf.resume_from), (
self.checkpoint_conf.resume_from f"The 'resume_from' checkpoint {self.checkpoint_conf.resume_from} does not exist!"
), f"The 'resume_from' checkpoint {self.checkpoint_conf.resume_from} does not exist!" )
dst = os.path.join(self.checkpoint_conf.save_dir, "checkpoint.pt") dst = os.path.join(self.checkpoint_conf.save_dir, "checkpoint.pt")
if self.distributed_rank == 0 and not os.path.exists(dst): if self.distributed_rank == 0 and not os.path.exists(dst):
# Copy the "resume_from" checkpoint to the checkpoint folder # Copy the "resume_from" checkpoint to the checkpoint folder
@@ -471,9 +471,9 @@ class Trainer:
return self.loss[key] return self.loss[key]
assert key != "all", "Loss must be specified for key='all'" assert key != "all", "Loss must be specified for key='all'"
assert ( assert "default" in self.loss, (
"default" in self.loss f"Key {key} not found in losss, and no default provided"
), f"Key {key} not found in losss, and no default provided" )
return self.loss["default"] return self.loss["default"]
def _find_meter(self, phase: str, key: str): def _find_meter(self, phase: str, key: str):
@@ -916,12 +916,12 @@ class Trainer:
self.optim.zero_grad(set_to_none=True) self.optim.zero_grad(set_to_none=True)
if self.gradient_accumulation_steps > 1: if self.gradient_accumulation_steps > 1:
assert isinstance( assert isinstance(batch, list), (
batch, list f"Expected a list of batches, got {type(batch)}"
), f"Expected a list of batches, got {type(batch)}" )
assert ( assert len(batch) == self.gradient_accumulation_steps, (
len(batch) == self.gradient_accumulation_steps f"Expected {self.gradient_accumulation_steps} batches, got {len(batch)}"
), f"Expected {self.gradient_accumulation_steps} batches, got {len(batch)}" )
accum_steps = len(batch) accum_steps = len(batch)
else: else:
accum_steps = 1 accum_steps = 1
@@ -1033,9 +1033,9 @@ class Trainer:
def _check_val_key_match(self, val_keys, phase): def _check_val_key_match(self, val_keys, phase):
if val_keys is not None: if val_keys is not None:
# Check if there are any duplicates # Check if there are any duplicates
assert len(val_keys) == len( assert len(val_keys) == len(set(val_keys)), (
set(val_keys) f"Duplicate keys in val datasets, keys: {val_keys}"
), f"Duplicate keys in val datasets, keys: {val_keys}" )
# Check that the keys match the meter keys # Check that the keys match the meter keys
if self.meters_conf is not None and phase in self.meters_conf: if self.meters_conf is not None and phase in self.meters_conf:
@@ -1049,9 +1049,9 @@ class Trainer:
loss_keys = set(self.loss_conf.keys()) - set(["all"]) loss_keys = set(self.loss_conf.keys()) - set(["all"])
if "default" not in loss_keys: if "default" not in loss_keys:
for k in val_keys: for k in val_keys:
assert ( assert k in loss_keys, (
k in loss_keys f"Error: key {k} is not defined in the losses, and no default is set"
), f"Error: key {k} is not defined in the losses, and no default is set" )
def _setup_components(self): def _setup_components(self):
# Get the keys for all the val datasets, if any # Get the keys for all the val datasets, if any
+3 -3
View File
@@ -243,9 +243,9 @@ def download_sav():
def main(): def main():
assert len(sys.argv) > 1, "You have to provide the name of the dataset" assert len(sys.argv) > 1, "You have to provide the name of the dataset"
dataset_name = sys.argv[1] dataset_name = sys.argv[1]
assert ( assert dataset_name in annotation_files, (
dataset_name in annotation_files f"The dataset can be one of {list(annotation_files.keys())}"
), f"The dataset can be one of {list(annotation_files.keys())}" )
if dataset_name == "yt1b": if dataset_name == "yt1b":
download_youtube() download_youtube()