You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

path_utils.py 1.8 kB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: UTF-8 -*-
  2. """
  3. Copyright 2020 Tianshu AI Platform. All Rights Reserved.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =============================================================
  14. """
  15. from pathlib import Path
  16. from .redis_utils import RedisInstance
  17. from .config_utils import ConfigInstance
  18. def id2logdir(uid, trainJobName):
  19. _base = Path(ConfigInstance.conf_logdir_base()).absolute()
  20. log_dir = _base / uid / trainJobName / "visualizedlog"
  21. try:
  22. int(uid)
  23. except ValueError:
  24. _base = Path("../demo_logs").absolute()
  25. log_dir = _base / uid / "logs"
  26. cache_dir = Path("../__cache__").absolute() / uid / trainJobName
  27. return log_dir, cache_dir
  28. def get_file_path(uid, run, type, tag):
  29. _key = uid + '_' + run + '_' + type + '_' + tag
  30. try:
  31. _path = Path(RedisInstance.get(_key))
  32. except TypeError:
  33. raise OSError('Redis key {} not found according to request '
  34. 'parameters, please check the parameters'
  35. .format(_key))
  36. return _path
  37. def path_parser(cache_path, run, type, tag):
  38. run = run if not (run == '.') else 'root'
  39. tag = tag.replace('/', '#').replace(':', '$')
  40. file_path = cache_path / run / type / tag
  41. return file_path

一站式算法开发平台、高性能分布式深度学习框架、先进算法模型库、视觉模型炼知平台、数据可视化分析平台等一系列平台及工具,在模型高效分布式训练、数据处理和可视分析、模型炼知和轻量化等技术上形成独特优势,目前已在产学研等各领域近千家单位及个人提供AI应用赋能

Contributors (1)