-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
012810d
commit 50b1ab4
Showing
6 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.1.0' | ||
__version__ = '0.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Modifications copyright (C) 2020 Bluefog Team. All Rights Reserved. | ||
# Copyright 2019 Uber Technologies, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
|
||
import sys | ||
from unittest.mock import MagicMock | ||
|
||
|
||
MOCK_MODULES = [ | ||
'cloudpickle', | ||
'ctypes', | ||
'psutil', | ||
|
||
'numpy', | ||
'numpy.core.multiarray', | ||
|
||
'tensorflow', | ||
'tensorflow.python', | ||
'tensorflow.python.framework', | ||
'tensorflow.python.platform', | ||
'tensorflow.python.eager', | ||
|
||
'torch', | ||
'torch.autograd.function', | ||
'torch.nn.functional', | ||
'torch.nn.modules.batchnorm', | ||
'torch.utils', | ||
'torch.utils.data', | ||
'torch.utils.tensorboard', | ||
|
||
'bluefog.common.util', | ||
'bluefog.torch.mpi_lib', | ||
'bluefog.tensorflow.mpi_lib', | ||
] | ||
|
||
|
||
MOCK_TREE = { | ||
'tensorflow': { | ||
'__version__': '2.0.0', | ||
'train': { | ||
'Optimizer': MagicMock, | ||
}, | ||
}, | ||
'torch': { | ||
'__version__': '1.4.0', | ||
}, | ||
'bluefog': { | ||
'common': { | ||
'util': { | ||
'get_ext_suffix': lambda: 'xyz', | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
|
||
def gen_mock_package(path): | ||
if type(path) == str: | ||
path = path.split('.') | ||
|
||
class TreeMock(MagicMock): | ||
@classmethod | ||
def __getattr__(cls, name): | ||
full_path = path + [name] | ||
tree_ptr = MOCK_TREE | ||
for path_part in full_path: | ||
if path_part in tree_ptr: | ||
if type(tree_ptr[path_part]) != dict: | ||
return tree_ptr[path_part] | ||
else: | ||
tree_ptr = tree_ptr[path_part] | ||
else: | ||
return MagicMock() | ||
return gen_mock_package(full_path) | ||
|
||
return TreeMock() | ||
|
||
|
||
def instrument(): | ||
sys.modules.update((mod_name, gen_mock_package(mod_name)) | ||
for mod_name in MOCK_MODULES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
bluefog | ||
matplotlib | ||
torch | ||
tensorflow | ||
networkx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters