查看日志 ========= .. contents:: 本节目录 :depth: 3 命令: ``log`` 可以用 ``log`` 命令查看运行日志。 ``--help`` 命令可看到有 ``training`` ``serving`` 子命令, 分别代表训练任务、验证任务、模型服务。目前CLI仅支持 `训练任务日志`_ 查看。 .. code-block:: shell anyctl log --help .. code-block:: text Usage: anyctl log [OPTIONS] COMMAND [ARGS]... Download remote task log of training or serving. Options: --help Show this message and exit. Commands: serving Get serving task's log. training Get training task's log. 训练任务日志 -------------- 命令: ``training`` +---------------------------+----------+-------------+-------------------------------------------------------------------+ | 参数及缩写 | 是否必须 | 默认值 | 说明 | +===========================+==========+=============+===================================================================+ | task_id | True | | 训练任务ID | +---------------------------+----------+-------------+-------------------------------------------------------------------+ | -\-type, -t | False | last | 日志查看类型["all", "last", "custom"] | +---------------------------+----------+-------------+-------------------------------------------------------------------+ | -\-save-path, -s | False | | 日志文件保存路径,仅当 -t 为"all"时需要 | +---------------------------+----------+-------------+-------------------------------------------------------------------+ | -\-direction, -d | False | init | 日志查询方向,仅 -t 为"custom"时需要 | +---------------------------+----------+-------------+-------------------------------------------------------------------+ | -\-limit, -l | False | 100 | 日志最大条数,仅 -t 为"custom"时需要 | +---------------------------+----------+-------------+-------------------------------------------------------------------+ | -\-offset, -o | False | 0 | 日志查询偏移量,仅 -t 为"custom"时需要 | +---------------------------+----------+-------------+-------------------------------------------------------------------+ | -\-offset-index, -oi | False | -1 | 日志查询的偏移量与"offset"一起用作分页基准,仅 -t 为"custom"时需要| +---------------------------+----------+-------------+-------------------------------------------------------------------+ | -\-debug | False | False | 显示更全面的调试信息,仅 -t 为"custom"时需要 | +---------------------------+----------+-------------+-------------------------------------------------------------------+ 其中参数 ``--type, -t`` 有三种类型可选, ``all`` ``last`` ``custom`` ,默认为 ``last``, 分别代表获取全部日志、获取最新日志、自定义日志数量。 获取全部日志 ^^^^^^^^^^^^^^^ 获取全部日志的话由于日志可能会比较多,所以此方式会把日志保存到文件,所以需要传入一个文件目录。 使用示例: .. code-block:: shell anyctl log training TRAIxxx -t all -s D:\anyctl-test\download\log 如果需要配置远程地址和用户信息请参考 :ref:`set_host_user_info` 。 运行后会有以下提示信息: .. code-block:: shell type is: all # 提示选取的日志类型 START GET LOG [SUCCESS] D:\anyctl-test\download\log/train_log_TRAIxxx.txt # 提示日志获取成功,并返回日志文件的路径 获取最新日志 ^^^^^^^^^^^^^^^ 获取最新日志会请求最多100条日志,以控制台直接输出的方式展示。 因为默认为 ``last`` 所以此时参数 ``type`` 可省略。 使用示例: .. code-block:: shell anyctl log training TRAIxxx 如果需要配置远程地址和用户信息请参考 :ref:`set_host_user_info` 。 运行后会有以下提示信息: .. code-block:: text type is: last START GET LOG ['[2021-08-10 18:25:03.621000+08:00] Collecting google-auth-oauthlib<0.5,>=0.4.1', '[2021-08-10 18:25:03.624000+08:00] Downloading https://pypi.tuna.tsinghua.edu.cn/packages/45/d9/df4019fc28b3aed8218e1bfca38158b90b70a3583c15f568ca669564dc24/google_auth_oauthlib-0.4.5-py2.py3-none-any.whl (18 kB)', '[2021-08-10 18:25:03.656000+08:00] Collecting tensorboard-plugin-wit>=1.6.0', '[2021-08-10 18:25:03.659000+08:00] Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1a/c1/499e600ba0c618b451cd9c425ae1c177249940a2086316552fee7d86c954/tensorboard_plugin_wit-1.8.0-py3-none-any.whl (781 kB)', '[2021-08-10 18:25:03.863000+08:00] Collecting google-auth<2,>=1.6.3', ' ... # 此处只截取一小部分展示 自定义日志数量 ^^^^^^^^^^^^^^^^^ 使用示例: .. code-block:: shell anyctl log training TRAIxxx -t custom -l 2 -o 0 如果需要配置远程地址和用户信息请参考 :ref:`set_host_user_info` 。 运行后会有以下提示信息: .. code-block:: shell type is: custom START GET LOG [{'offset': 1628591126613, 'offset_index': 25675, 'text': 'Task TRAIxxx finished.'}, {'offset': 1628591126613, 'offset_index': 25500, 'text': '[Anylearn]-Tue, 10 Aug 2021 18:25:26 - __main__ - INFO - Task TRAIxxx finished.'}] [SUCCESS] GET LOG 模型服务日志 --------------- 命令: ``serving`` *CLI暂不支持此功能*