2020-12-15 17:59:13 +00:00
|
|
|
# Copyright The PyTorch Lightning team.
|
|
|
|
#
|
|
|
|
# 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.
|
2021-03-02 09:47:55 +00:00
|
|
|
import logging
|
2020-04-02 16:28:44 +00:00
|
|
|
import os
|
|
|
|
|
2020-04-22 00:33:10 +00:00
|
|
|
import numpy as np
|
|
|
|
|
2020-12-23 23:11:42 +00:00
|
|
|
_TEST_ROOT = os.path.dirname(__file__)
|
|
|
|
_PROJECT_ROOT = os.path.dirname(_TEST_ROOT)
|
|
|
|
_TEMP_PATH = os.path.join(_PROJECT_ROOT, 'test_temp')
|
2021-01-08 15:36:49 +00:00
|
|
|
DATASETS_PATH = os.path.join(_PROJECT_ROOT, 'Datasets')
|
|
|
|
LEGACY_PATH = os.path.join(_PROJECT_ROOT, 'legacy')
|
2020-12-02 10:00:05 +00:00
|
|
|
|
2020-12-07 09:31:33 +00:00
|
|
|
# todo: this setting `PYTHONPATH` may not be used by other evns like Conda for import packages
|
2020-12-23 23:11:42 +00:00
|
|
|
if _PROJECT_ROOT not in os.getenv('PYTHONPATH', ""):
|
2020-12-07 09:31:33 +00:00
|
|
|
splitter = ":" if os.environ.get("PYTHONPATH", "") else ""
|
2020-12-23 23:11:42 +00:00
|
|
|
os.environ['PYTHONPATH'] = f'{_PROJECT_ROOT}{splitter}{os.environ.get("PYTHONPATH", "")}'
|
2020-04-22 00:33:10 +00:00
|
|
|
|
|
|
|
# generate a list of random seeds for each test
|
|
|
|
RANDOM_PORTS = list(np.random.randint(12000, 19000, 1000))
|
|
|
|
|
2020-12-23 23:11:42 +00:00
|
|
|
if not os.path.isdir(_TEMP_PATH):
|
|
|
|
os.mkdir(_TEMP_PATH)
|
2021-03-02 09:47:55 +00:00
|
|
|
|
|
|
|
logging.basicConfig(level=logging.ERROR)
|