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

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

Contributors (1)