Skip to content
Open
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
2 changes: 1 addition & 1 deletion examples/core/rgcn/hetero_rgcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def main(args):
if embed_layer is not None:
embed_layer.reset_parameters()
model.reset_parameters()
except:
except Exception:
# Old pytorch version doesn't support reset_parameters() API.
##################################################################
# [Why we need to reset the parameters?]
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/argo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _train(**kwargs):
loss = F.cross_entropy(
y_hat[: output_nodes.shape[0]], y[: output_nodes.shape[0]]
)
except:
except Exception:
loss = F.binary_cross_entropy_with_logits(
y_hat[: output_nodes.shape[0]].float(),
y[: output_nodes.shape[0]].float(),
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/graphsim/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def eval_rollout(model, prep, initial_frame, n_object, device):
e, valid_loss, test_full_loss
)
)
except:
except Exception:
traceback.print_exc()
finally:
if args.visualize:
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/hilander/PSS/train_subg_inat.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def set_train_sampler_loader(g, k):
for loader_id in range(num_loaders):
try:
minibatch = next(train_loaders[loader_id])
except:
except Exception:
train_loaders[loader_id] = iter(
set_train_sampler_loader(gs[loader_id], ks[loader_id])
)
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/hilander/train_subg.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def set_train_sampler_loader(g, k):
for loader_id in range(num_loaders):
try:
minibatch = next(train_loaders[loader_id])
except:
except Exception:
train_loaders[loader_id] = iter(
set_train_sampler_loader(gs[loader_id], ks[loader_id])
)
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/jtnn/vaetrain_dgl.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def train():
model.zero_grad()
try:
loss, kl_div, wacc, tacc, sacc, dacc = model(batch, beta)
except:
except Exception:
print([t.smiles for t in batch["mol_trees"]])
raise
loss.backward()
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/ogb/deepwalk/load_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def load_from_ogbl_with_name(name):
try:
w = g.edata["edge_weight"]
weighted = True
except:
except Exception:
weighted = False

edge_num = g.edges()[0].shape[0]
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/ogb/deepwalk/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def save_embedding_pt(self, dataset, file_name):
torch.sum(embedding.mul(embedding), 1) + 1e-6
).unsqueeze(1)
torch.save(embedding, file_name)
except:
except Exception:
self.save_embedding_pt_dgl_graph(dataset, file_name)

def save_embedding_pt_dgl_graph(self, dataset, file_name):
Expand Down
8 changes: 4 additions & 4 deletions examples/pytorch/ogb/deepwalk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ def sum_up_params(model):

try:
n.append(model.index_emb_negu.cpu().numel() * 2)
except:
except Exception:
pass
try:
n.append(model.state_sum_u.cpu().numel() * 2)
except:
except Exception:
pass
try:
n.append(model.grad_avg.cpu().numel())
except:
except Exception:
pass
try:
n.append(model.context_weight.cpu().numel())
except:
except Exception:
pass

print("#params " + str(sum(n)))
Expand Down
2 changes: 1 addition & 1 deletion examples/pytorch/ogb/line/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def sum_up_params(model):
n.append(model.lookup_table.cpu().numel())
try:
n.append(model.index_emb_negu.cpu().numel() * 2)
except:
except Exception:
pass
print("#params " + str(sum(n)))
2 changes: 1 addition & 1 deletion examples/pytorch/ogb/ogbn-mag/hetero_rgcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def main(args):
try:
embed_layer.reset_parameters()
model.reset_parameters()
except:
except Exception:
# old pytorch version doesn't support reset_parameters() API
pass

Expand Down
2 changes: 1 addition & 1 deletion python/dgl/_ffi/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def copyfrom(self, source_array):
if not isinstance(source_array, np.ndarray):
try:
source_array = np.asarray(source_array, dtype=self.dtype)
except:
except Exception:
raise TypeError(
"array must be an array_like data,"
+ "type %s is not supported" % str(type(source_array))
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/data/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def process(self):
self.train_idx = F.nonzero_1d(self.dataset.train_mask)
self.val_idx = F.nonzero_1d(self.dataset.val_mask)
self.test_idx = F.nonzero_1d(self.dataset.test_mask)
except:
except Exception:
raise DGLError(
"The input dataset does not have default train/val/test\
split. Please specify split_ratio to generate the split."
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/data/dgl_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _load(self):
print("Done loading data from cached files.")
except KeyboardInterrupt:
raise
except:
except Exception:
load_flag = False
if self.verbose:
print(traceback.format_exc())
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/dataloading/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ def enable_cpu_affinity(
def init_fn(worker_id):
try:
psutil.Process().cpu_affinity([loader_cores[worker_id]])
except:
except Exception:
raise Exception(
"ERROR: cannot use affinity id={} cpu={}".format(
worker_id, loader_cores
Expand Down
4 changes: 2 additions & 2 deletions python/dgl/distgnn/partition/libra_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def partition_graph(num_community, G, resultdir):
## create ouptut directory
try:
os.makedirs(resultdir, mode=0o775, exist_ok=True)
except:
except Exception:
raise DGLError("Error: Could not create directory: ", resultdir)

tic = time.time()
Expand All @@ -329,7 +329,7 @@ def partition_graph(num_community, G, resultdir):
try:
resultdir = os.path.join(resultdir, str(num_community) + "Communities")
os.makedirs(resultdir, mode=0o775, exist_ok=True)
except:
except Exception:
raise DGLError("Error: Could not create sub-directory: ", resultdir)

## Libra partitioning
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/distgnn/tools/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def download_proteins():
url = url + file_name
try:
req = requests.get(url)
except:
except Exception:
raise DGLError(
"Error: Failed to download Proteins dataset!! Aborting.."
)
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/utils/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ def wrapper(self, *args, **kwargs):
# pylint: disable=W0703,bare-except
try:
return func(self, *args, **kwargs)
except:
except Exception:
fix_method(self)
return func(self, *args, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions tests/distributed/test_dist_graph_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def check_dist_graph(g, num_clients, num_nodes, num_edges, use_graphbolt=False):
(g.num_nodes(), 3), F.float32, "test4"
)
raise Exception("")
except:
except Exception:
pass

# Test write data
Expand Down Expand Up @@ -876,7 +876,7 @@ def check_dist_graph_hetero(
(g.num_nodes("n1"), 3), F.float32, "test4"
)
raise Exception("")
except:
except Exception:
pass

# Test write data
Expand Down
2 changes: 1 addition & 1 deletion tests/distributed/test_distributed_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def check_rpc_hetero_find_edges_shuffle(tmpdir, num_server):
expect_except = False
try:
_, _ = g.find_edges(orig_eid[test_etype][eids], etype=("n1", "r12"))
except:
except Exception:
expect_except = True
assert expect_except
u, v = g.find_edges(orig_eid[test_etype][eids], etype="r12")
Expand Down
2 changes: 1 addition & 1 deletion tests/distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def generate_ip_config(file_name, num_machines, num_servers):
try:
sock.connect((ip, port))
ports = []
except:
except Exception:
ports.append(port)
if len(ports) == num_machines * num_servers:
break
Expand Down
14 changes: 7 additions & 7 deletions tests/python/common/data/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def _test_construct_graphs_node_ids():
expect_except = False
try:
_, _ = DGLGraphConstructor.construct_graphs(node_data, edge_data)
except:
except Exception:
expect_except = True
assert expect_except

Expand Down Expand Up @@ -732,7 +732,7 @@ def assert_data(lhs, rhs, size, node=False):
_, _ = DGLGraphConstructor.construct_graphs(
node_data, edge_data, graph_data
)
except:
except Exception:
expect_except = True
assert expect_except

Expand Down Expand Up @@ -781,7 +781,7 @@ def _test_DefaultDataParser():
expect_except = False
try:
_get_data_table(df)
except:
except Exception:
expect_except = True
assert expect_except

Expand Down Expand Up @@ -887,7 +887,7 @@ def _test_load_yaml_with_sanity_check():
expect_except = False
try:
meta = load_yaml_with_sanity_check(yaml_path)
except:
except Exception:
expect_except = True
assert expect_except
# inapplicable version
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def _test_load_node_data_from_csv():
expect_except = False
try:
NodeData.load_from_csv(meta_node, DefaultDataParser())
except:
except Exception:
expect_except = True
assert expect_except

Expand Down Expand Up @@ -1569,7 +1569,7 @@ def _test_NodeEdgeGraphData():
{"feat": np.random.rand(num_nodes + 1, 3)},
graph_id=np.arange(num_nodes - 1),
)
except:
except Exception:
expect_except = True
assert expect_except

Expand Down Expand Up @@ -1608,7 +1608,7 @@ def _test_NodeEdgeGraphData():
{"feat": np.random.rand(num_edges - 1, 3)},
graph_id=np.arange(num_edges + 2),
)
except:
except Exception:
expect_except = True
assert expect_except

Expand Down
2 changes: 1 addition & 1 deletion tests/python/common/data/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def test_graph_serialize_with_restricted_formats():
expect_except = False
try:
dgl.save_graphs(path, g_list, formats=["csr"])
except:
except Exception:
expect_except = True
assert expect_except

Expand Down
2 changes: 1 addition & 1 deletion tests/python/common/function/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def test_update_routines(idtype):
try:
g.send_and_recv([u, v])
assert False
except:
except Exception:
pass

# pull
Expand Down
8 changes: 4 additions & 4 deletions tests/python/common/test_heterograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,14 @@ def test_empty_query(idtype):
try:
g.in_degrees([0])
fail = False
except:
except Exception:
pass
assert error_thrown
error_thrown = True
try:
g.out_degrees([0])
fail = False
except:
except Exception:
pass
assert error_thrown

Expand Down Expand Up @@ -3111,7 +3111,7 @@ def test_remove_edges(idtype):
assert_fail = False
try:
g.remove_edges(1)
except:
except Exception:
assert_fail = True
assert assert_fail

Expand Down Expand Up @@ -3221,7 +3221,7 @@ def test_remove_nodes(idtype):
assert_fail = False
try:
g.remove_nodes(3)
except:
except Exception:
assert_fail = True
assert assert_fail

Expand Down
Loading