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.

dictionary_watcher.py 1.8 kB

5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- coding: UTF-8 -*-
  2. # Copyright 2020 Zhejiang Lab. All Rights Reserved.
  3. #
  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. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # =============================================================
  16. import os
  17. from watchdog.observers.polling import PollingObserver
  18. from watchdog.events import *
  19. from python_io.logfile_loader import Trace_Thread
  20. from .logfile_utils import *
  21. class Watcher_Handler(FileSystemEventHandler):
  22. def __init__(self, run, uid, cache_path):
  23. self.runname = run
  24. self.uid = uid
  25. self.cache_path = cache_path
  26. def on_created(self, event):
  27. print("创建--> %s" % event.src_path)
  28. filename = Path(event.src_path)
  29. if filename.is_file():
  30. if is_available_flie(event.src_path):
  31. current_size = os.path.getsize(event.src_path)
  32. Trace_Thread(self.runname, filename, current_size,
  33. self.uid, self.cache_path).start()
  34. else:
  35. print("非有效日志文件 %s" % filename.name)
  36. else:
  37. pass
  38. def start_run_watcher(run, path, uid, cache_path):
  39. event_handler = Watcher_Handler(run, uid, cache_path)
  40. observer = PollingObserver()
  41. observer.schedule(event_handler, path, recursive=False)
  42. observer.start()

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

Contributors (1)