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.

debugger_folder_analyzer.py 1.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright 2021 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Debugger train job register."""
  16. import os
  17. from mindinsight.utils.folder_analyzer import FolderAnalyzer
  18. from mindinsight.datavisual.common.log import logger
  19. class DebuggerFolderAnalyzer(FolderAnalyzer):
  20. """Debugger train job register."""
  21. def analyze(self, entry, summary_base_dir, relative_path):
  22. """Check dir by debugger register."""
  23. update_info = {}
  24. if entry.is_dir():
  25. sub_relative_path = os.path.join(relative_path, entry.name)
  26. entry_path = os.path.join(summary_base_dir, sub_relative_path)
  27. try:
  28. subdir_entries = os.scandir(entry_path)
  29. except PermissionError:
  30. logger.warning('Path of %s under summary base directory is not accessible.', entry.name)
  31. return update_info
  32. subdir_entries = [subdir_entry for subdir_entry in subdir_entries if not subdir_entry.is_symlink()]
  33. subdir_entries = sorted(subdir_entries, key=lambda x: x.stat().st_mtime)
  34. for subdir_entry in subdir_entries:
  35. if subdir_entry.is_dir() and subdir_entry.name.startswith(".metadata"):
  36. update_info = {'dump_dir': sub_relative_path}
  37. return update_info
  38. return update_info