MCPcopy Create free account
hub / github.com/apple/axlearn / set_data_dir

Function set_data_dir

axlearn/common/utils.py:1532–1556  ·  view source on GitHub ↗

Sets the environment variable DATA_DIR to the given `data_dir`. Args: data_dir: The data_dir. Raises: ValueError: If the environment variable DATA_DIR is already set to a different value.

(data_dir: Optional[str])

Source from the content-addressed store, hash-verified

1530 partial_fn = functools.partial(fn, *args, **kwargs)
1531 return functools.update_wrapper(partial_fn, fn)
1532
1533
1534def prune_tree(
1535 in_tree: NestedTensor,
1536 should_prune: Callable[[str, NestedTensor], bool],
1537 *,
1538 prefix: str = "",
1539 separator: str = "/",
1540):
1541 """Returns a shallow copy of the input tree with subtrees pruned based on `should_prune`.
1542
1543 This is a shallow copy because leaf nodes (non-dict values) are not deep-copied.
1544
1545 Args:
1546 in_tree: The input tree to be pruned.
1547 should_prune: A callable which takes (path, subtree) as input and returns a boolean. The
1548 subtree provided will have already been pruned. If the callable returns True, the
1549 subtree itself will be dropped.
1550 prefix: Path prefix.
1551 separator: Separator used to join path parts.
1552
1553 Returns:
1554 The pruned copy of the input tree.
1555 """
1556 if isinstance(in_tree, dict):
1557 # Use type() so that if in_tree is a VDict, out_tree is also a VDict.
1558 out_tree = type(in_tree)()
1559 for k, v in in_tree.items():

Callers 15

named_parametersFunction · 0.90
_golden_runMethod · 0.90
mainFunction · 0.90
test_input_configMethod · 0.90
target_to_sourceMethod · 0.90
checkFunction · 0.90
check_initFunction · 0.90
_per_param_textFunction · 0.90
test_mainFunction · 0.90
test_pipelineMethod · 0.90

Calls 3

get_data_dirFunction · 0.85
push_data_dirFunction · 0.85
pop_data_dirFunction · 0.85

Tested by 12

named_parametersFunction · 0.72
_golden_runMethod · 0.72
test_input_configMethod · 0.72
test_mainFunction · 0.72
test_pipelineMethod · 0.72
test_get_and_setMethod · 0.72
test_output_writerMethod · 0.72