[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-huggingface--knockknock":3,"tool-huggingface--knockknock":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",151314,2,"2026-04-11T23:32:58",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":76,"owner_twitter":72,"owner_website":77,"owner_url":78,"languages":79,"stars":84,"forks":85,"last_commit_at":86,"license":87,"difficulty_score":32,"env_os":88,"env_gpu":89,"env_ram":89,"env_deps":90,"category_tags":96,"github_topics":97,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":109,"updated_at":110,"faqs":111,"releases":147},6745,"huggingface\u002Fknockknock","knockknock","🚪✊Knock Knock: Get notified when your training ends with only two additional lines of code","knockknock 是一款专为深度学习训练过程设计的轻量级通知工具。在训练大型模型时，由于常使用早停机制或遭遇意外崩溃，开发者很难准确预估任务结束时间，往往需要时刻盯着屏幕或频繁手动检查进度。knockknock 完美解决了这一痛点，它能在训练完成或中途报错时，立即通过多种渠道向你发送提醒，让你从枯燥的等待中解放出来。\n\n这款工具主要面向 AI 研究人员、数据科学家及后端开发者。其最大的技术亮点在于极致的易用性：无需重构现有代码逻辑，只需在主训练函数上方添加两行装饰器代码即可生效。此外，它还支持将函数的返回值一并包含在通知内容中，方便快速了解训练结果。\n\n为了适应不同的协作环境，knockknock 提供了高达十二种通知方式，涵盖电子邮件、Slack、Telegram、微信企业版、钉钉、短信以及桌面弹窗等主流平台。无论是个人单机实验还是团队协同开发，你都能找到适合的通知渠道。作为一个由 Hugging Face 社区支持的开源项目，knockknock 以最小的代码侵入性，显著提升了模型训练的工作流效率，是深度学习从业者提升生产力的实用小助手。","# Knock Knock\n\n[![made-with-python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMade%20with-Python-red.svg)](#python) [![Downloads](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_knockknock_readme_34c50e933400.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fknockknock) [![Downloads](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_knockknock_readme_34c50e933400.png\u002Fmonth)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fknockknock\u002Fmonth) [![GitHub stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fhuggingface\u002Fknockknock.svg?style=social&label=Star&maxAge=1000)](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fstargazers\u002F)\n\nA small library to get a notification when your training is complete or when it crashes during the process with two additional lines of code.\n\nWhen training deep learning models, it is common to use early stopping. Apart from a rough estimate, it is difficult to predict when the training will finish. Thus, it can be interesting to set up automatic notifications for your training. It is also interesting to be notified when your training crashes in the middle of the process for unexpected reasons.\n\n## Installation\n\nInstall with `pip` or equivalent.\n\n```bash\npip install knockknock\n```\n\nThis code has only been tested with Python >= 3.6.\n\n## Usage\n\nThe library is designed to be used in a seamless way, with minimal code modification: you only need to add a decorator on top your main function call. The return value (if there is one) is also reported in the notification.\n\nThere are currently *twelve* ways to setup notifications:\n\n|               Platform                |                                   External Contributors                                   |\n| :-----------------------------------: | :---------------------------------------------------------------------------------------: |\n|            [email](#email)            |                                             -                                             |\n|            [Slack](#slack)            |                                             -                                             |\n|         [Telegram](#telegram)         |                                             -                                             |\n|  [Microsoft Teams](#microsoft-teams)  |                           [@noklam](https:\u002F\u002Fgithub.com\u002Fnoklam)                            |\n| [Text Message](\u003C#text-message-(sms)>) |                 [@abhishekkrthakur](https:\u002F\u002Fgithub.com\u002Fabhishekkrthakur)                  |\n|          [Discord](#discord)          |                         [@watkinsm](https:\u002F\u002Fgithub.com\u002Fwatkinsm)                          |\n|   [Desktop](#desktop-notification)    | [@atakanyenel](https:\u002F\u002Fgithub.com\u002Fatakanyenel) [@eyalmazuz](https:\u002F\u002Fgithub.com\u002Feyalmazuz) |\n|           [Matrix](#matrix)           |                           [@jcklie](https:\u002F\u002Fgithub.com\u002Fjcklie)                            |\n|     [Amazon Chime](#amazon-chime)     |                     [@prabhakar267](https:\u002F\u002Fgithub.com\u002Fprabhakar267)                      |\n|         [DingTalk](#dingtalk)         |                         [@wuutiing](https:\u002F\u002Fgithub.com\u002Fwuutiing)                          |\n|       [RocketChat](#rocketchat)       |                            [@radao](https:\u002F\u002Fgithub.com\u002Fradao)                             |\n|      [WeChat Work](#wechat-work)      |                             [@jcyk](https:\u002F\u002Fgithub.com\u002Fjcyk)                              |\n\n\n### Email\n\nThe service relies on [Yagmail](https:\u002F\u002Fgithub.com\u002Fkootenpv\u002Fyagmail) a GMAIL\u002FSMTP client. You'll need a gmail email address to use it (you can setup one [here](https:\u002F\u002Faccounts.google.com), it's free). I recommend creating a new one (rather than your usual one) since you'll have to modify the account's security settings to allow the Python library to access it by [Turning on less secure apps](https:\u002F\u002Fdevanswers.co\u002Fallow-less-secure-apps-access-gmail-account\u002F).\n\n#### Python\n\n```python\nfrom knockknock import email_sender\n\n@email_sender(recipient_emails=[\"\u003Cyour_email@address.com>\", \"\u003Cyour_second_email@address.com>\"], sender_email=\"\u003Cgrandma's_email@gmail.com>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock email \\\n    --recipient-emails \u003Cyour_email@address.com>,\u003Cyour_second_email@address.com> \\\n    --sender-email \u003Cgrandma's_email@gmail.com> \\\n    sleep 10\n```\n\nIf `sender_email` is not specified, then the first email in `recipient_emails` will be used as the sender's email.\n\nNote that launching this will asks you for the sender's email password. It will be safely stored in the system keyring service through the [`keyring` Python library](https:\u002F\u002Fpypi.org\u002Fproject\u002Fkeyring\u002F).\n\n\n### Slack\n\nSimilarly, you can also use Slack to get notifications. You'll have to get your Slack room [webhook URL](https:\u002F\u002Fapi.slack.com\u002Fincoming-webhooks#create_a_webhook) and optionally your [user id](https:\u002F\u002Fapi.slack.com\u002Fmethods\u002Fusers.identity) (if you want to tag yourself or someone else).\n\n#### Python\n\n```python\nfrom knockknock import slack_sender\n\nwebhook_url = \"\u003Cwebhook_url_to_your_slack_room>\"\n@slack_sender(webhook_url=webhook_url, channel=\"\u003Cyour_favorite_slack_channel>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\nYou can also specify an optional argument to tag specific people: `user_mentions=[\u003Cyour_slack_id>, \u003Cgrandma's_slack_id>]`.\n\n#### Command-line\n\n```bash\nknockknock slack \\\n    --webhook-url \u003Cwebhook_url_to_your_slack_room> \\\n    --channel \u003Cyour_favorite_slack_channel> \\\n    sleep 10\n```\n\nYou can also specify an optional argument to tag specific people: `--user-mentions \u003Cyour_slack_id>,\u003Cgrandma's_slack_id>`.\n\n\n### Telegram\n\nYou can also use Telegram Messenger to get notifications. You'll first have to create your own notification bot by following the three steps provided by Telegram [here](https:\u002F\u002Fcore.telegram.org\u002Fbots#6-botfather) and save your API access `TOKEN`.\n\nTelegram bots are shy and can't send the first message so you'll have to do the first step. By sending the first message, you'll be able to get the `chat_id` required (identification of your messaging room) by visiting `https:\u002F\u002Fapi.telegram.org\u002Fbot\u003CYourBOTToken>\u002FgetUpdates` and get the `int` under the key `message['chat']['id']`.\n\n#### Python\n\n```python\nfrom knockknock import telegram_sender\n\nCHAT_ID: int = \u003Cyour_messaging_room_id>\n@telegram_sender(token=\"\u003Cyour_api_token>\", chat_id=CHAT_ID)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock telegram \\\n    --token \u003Cyour_api_token> \\\n    --chat-id \u003Cyour_messaging_room_id> \\\n    sleep 10\n```\n\n\n### Microsoft Teams\n\nThanks to [@noklam](https:\u002F\u002Fgithub.com\u002Fnoklam), you can also use Microsoft Teams to get notifications. You'll have to get your Team Channel [webhook URL](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fmicrosoftteams\u002Fplatform\u002Fconcepts\u002Fconnectors\u002Fconnectors-using).\n\n#### Python\n\n```python\nfrom knockknock import teams_sender\n\n@teams_sender(token=\"\u003Cwebhook_url_to_your_teams_channel>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock teams \\\n    --webhook-url \u003Cwebhook_url_to_your_teams_channel> \\\n    sleep 10\n```\n\nYou can also specify an optional argument to tag specific people: `user_mentions=[\u003Cyour_teams_id>, \u003Cgrandma's_teams_id>]`.\n\n\n### Text Message (SMS)\n\nThanks to [@abhishekkrthakur](https:\u002F\u002Fgithub.com\u002Fabhishekkrthakur), you can use Twilio to send text message notifications. You'll have to setup a [Twilio](www.twilio.com) account [here](https:\u002F\u002Fwww.twilio.com\u002Ftry-twilio), which is paid service with competitive prices: for instance in the US, getting a new number and sending one text message through this service respectively cost $1.00 and $0.0075. You'll need to get (a) a phone number, (b) your [account SID](https:\u002F\u002Fwww.twilio.com\u002Fdocs\u002Fglossary\u002Fwhat-is-a-sid) and (c) your [authentification token](https:\u002F\u002Fwww.twilio.com\u002Fdocs\u002Fiam\u002Faccess-tokens). Some detail [here](https:\u002F\u002Fwww.twilio.com\u002Fdocs\u002Fiam\u002Fapi\u002Faccount).\n\n#### Python\n\n```python\nfrom knockknock import sms_sender\n\nACCOUNT_SID: str = \"\u003Cyour_account_sid>\"\nAUTH_TOKEN: str = \"\u003Cyour_auth_token>\"\n@sms_sender(account_sid=ACCOUNT_SID, auth_token=AUTH_TOKEN, recipient_number=\"\u003Crecipient's_number>\", sender_number=\"\u003Csender's_number>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock sms \\\n    --account-sid \u003Cyour_account_sid> \\\n    --auth-token \u003Cyour_account_auth_token> \\\n    --recipient-number \u003Crecipient_number> \\\n    --sender-number \u003Csender_number>\n    sleep 10\n```\n\n\n### Discord\n\nThanks to [@watkinsm](https:\u002F\u002Fgithub.com\u002Fwatkinsm), you can also use Discord to get notifications. You'll just have to get your Discord channel's [webhook URL](https:\u002F\u002Fsupport.discordapp.com\u002Fhc\u002Fen-us\u002Farticles\u002F228383668-Intro-to-Webhooks).\n\n#### Python\n\n```python\nfrom knockknock import discord_sender\n\nwebhook_url = \"\u003Cwebhook_url_to_your_discord_channel>\"\n@discord_sender(webhook_url=webhook_url)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock discord \\\n    --webhook-url \u003Cwebhook_url_to_your_discord_channel> \\\n    sleep 10\n```\n\n\n### Desktop Notification\n\nYou can also get notified from a desktop notification. It is currently only available for MacOS and Linux and Windows 10.\nFor Linux it uses the nofity-send command which uses libnotify, In order to use libnotify, you have to install a notification server. Cinnamon, Deepin, Enlightenment, GNOME, GNOME Flashback and KDE Plasma use their own implementations to display notifications. In other desktop environments, the notification server needs to be launched using your WM's\u002FDE's \"autostart\" option.\n\n#### Python\n\n```python\nfrom knockknock import desktop_sender\n\n@desktop_sender(title=\"Knockknock Desktop Notifier\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {\"loss\": 0.9}\n```\n\n#### Command Line\n\n```bash\nknockknock desktop \\\n    --title 'Knockknock Desktop Notifier' \\\n    sleep 2\n```\n\n### Matrix\n\nThanks to [@jcklie](https:\u002F\u002Fgithub.com\u002Fjcklie), you can send notifications via [Matrix](https:\u002F\u002Fmatrix.org\u002F). The homeserver is the\nserver on which your user that will send messages is registered. Do not forget the schema for the URL (`http` or `https`).\nYou'll have to get the access token for a bot or your own user. The easiest way to obtain it is to look into Riot looking\nin the riot settings, `Help & About`, down the bottom is: `Access Token:\u003Cclick to reveal>`. You also need to specify a\nroom alias to which messages are sent. To obtain the alias in Riot, create a room you want to use, then open the room\nsettings under `Room Addresses` and add an alias.\n\n#### Python\n\n```python\nfrom knockknock import matrix_sender\n\nHOMESERVER = \"\u003Curl_to_your_home_server>\" # e.g. https:\u002F\u002Fmatrix.org\nTOKEN = \"\u003Cyour_auth_token>\"              # e.g. WiTyGizlr8ntvBXdFfZLctyY\nROOM = \"\u003Croom_alias\"                     # e.g. #knockknock:matrix.org\n\n@matrix_sender(homeserver=HOMESERVER, token=TOKEN, room=ROOM)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock matrix \\\n    --homeserver \u003Chomeserver> \\\n    --token \u003Ctoken> \\\n    --room \u003Croom> \\\n    sleep 10\n```\n\n\n### Amazon Chime\n\nThanks to [@prabhakar267](https:\u002F\u002Fgithub.com\u002Fprabhakar267), you can also use Amazon Chime to get notifications. You'll have to get your Chime room [webhook URL](https:\u002F\u002Fdocs.aws.amazon.com\u002Fchime\u002Flatest\u002Fdg\u002Fwebhooks.html).\n\n#### Python\n\n```python\nfrom knockknock import chime_sender\n\n@chime_sender(webhook_url=\"\u003Cwebhook_url_to_your_chime_room>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock chime \\\n    --webhook-url \u003Cwebhook_url_to_your_chime_room> \\\n    sleep 10\n```\n\nYou can also specify an optional argument to tag specific people: `user_mentions=[\u003Cyour_alias>, \u003Cgrandma's_alias>]`.\n\n\n### DingTalk\n\nDingTalk is now supported thanks to [@wuutiing](https:\u002F\u002Fgithub.com\u002Fwuutiing). Given DingTalk chatroom robot's webhook url and secret\u002Fkeywords(at least one of them are set when creating a chatroom robot), your notifications will be sent to reach any one in that chatroom.\n\n#### Python\n\n```python\nfrom knockknock import dingtalk_sender\n\nwebhook_url = \"\u003Cwebhook_url_to_your_dingtalk_chatroom_robot>\"\n@dingtalk_sender(webhook_url=webhook_url, secret=\"\u003Cyour_robot_secret_if_set>\", keywords=[\"\u003Clist_of_keywords_if_set>\"])\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock dingtalk \\\n    --webhook-url \u003Cwebhook_url_to_your_dingtalk_chatroom_robot> \\\n    --secret \u003Cyour_robot_secret_if_set> \\\n    sleep 10\n```\n\nYou can also specify an optional argument to at specific people: `user_mentions=[\"\u003Clist_of_phonenumbers_who_you_want_to_tag>\"]`.\n\n\n### RocketChat\n\nYou can use [RocketChat](https:\u002F\u002Frocket.chat\u002F) to get notifications. You'll need the following before you can post notifications:\n\n- a RocketChat server e.g. rocketchat.yourcompany.com\n- a RocketChat user id (you'll be able to view your user id when you create a personal access token in the next step)\n- a RocketChat personal access token ([create one as per this guide](https:\u002F\u002Frocket.chat\u002Fdocs\u002Fdeveloper-guides\u002Frest-api\u002Fpersonal-access-tokens\u002F))\n- a RocketChat channel\n\n#### Python\n\n```python\nfrom knockknock import rocketchat_sender\n\n@rocketchat_sender(\n    rocketchat_server_url=\"\u003Curl_to_your_rocketchat_server>\",\n    rocketchat_user_id=\"\u003Cyour_rocketchat_user_id>\",\n    rocketchat_auth_token=\"\u003Cyour_rocketchat_auth_token>\",\n    channel=\"\u003Cchannel_name>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\nYou can also specify two optional arguments:\n\n- to tag specific users: `user_mentions=[\u003Cyour_user_name>, \u003Cgrandma's_user_name>]`\n- to use an alias for the notification: `alias=\"My Alias\"`\n\n#### Command-line\n\n```bash\nknockknock rocketchat \\\n    --rocketchat-server-url \u003Curl_to_your_rocketchat_server> \\\n    --rocketchat-user-id \u003Cyour_rocketchat_user_id> \\\n    --rocketchat-auth-token \u003Cyour_rocketchat_auth_token> \\\n    --channel \u003Cchannel_name> \\\n    sleep 10\n```\n\n\n### WeChat Work\n\nWeChat Work is now supported thanks to [@jcyk](https:\u002F\u002Fgithub.com\u002Fjcyk). Given WeChat Work chatroom robot's webhook url, your notifications will be sent to reach anyone in that chatroom.\n\n#### Python\n\n```python\nfrom knockknock import wechat_sender\n\nwebhook_url = \"\u003Cwebhook_url_to_your_wechat_work_chatroom_robot>\"\n@wechat_sender(webhook_url=webhook_url)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # Optional return value\n```\n\n#### Command-line\n\n```bash\nknockknock wechat \\\n    --webhook-url \u003Cwebhook_url_to_your_wechat_work_chatroom_robot> \\\n    sleep 10\n```\n\nYou can also specify an optional argument to tag specific people: `user-mentions=[\"\u003Clist_of_userids_you_want_to_tag>\"]` and\u002For `user-mentions-mobile=[\"\u003Clist_of_phonenumbers_you_want_to_tag>\"]`.\n\n\n## Note on distributed training\n\nWhen using distributed training, a GPU is bound to its process using the local rank variable. Since knockknock works at the process level, if you are using 8 GPUs, you would get 8 notifications at the beginning and 8 notifications at the end... To circumvent that, except for errors, only the master process is allowed to send notifications so that you receive only one notification at the beginning and one notification at the end.\n\n**Note:** _In PyTorch, the launch of `torch.distributed.launch` sets up a RANK environment variable for each process (see [here](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Fblob\u002Fmaster\u002Ftorch\u002Fdistributed\u002Flaunch.py#L211)). This is used to detect the master process, and for now, the only simple way I came up with. Unfortunately, this is not intended to be general for all platforms but I would happily discuss smarter\u002Fbetter ways to handle distributed training in an issue\u002FPR._\n","# 敲敲门\n\n[![made-with-python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMade%20with-Python-red.svg)](#python) [![下载量](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_knockknock_readme_34c50e933400.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fknockknock) [![下载量](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_knockknock_readme_34c50e933400.png\u002Fmonth)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fknockknock\u002Fmonth) [![GitHub 星标](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fhuggingface\u002Fknockknock.svg?style=social&label=Star&maxAge=1000)](https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fstargazers\u002F)\n\n一个小型库，只需添加两行代码，即可在训练完成或过程中发生崩溃时收到通知。\n\n在训练深度学习模型时，通常会使用早停策略。除了粗略的估计外，很难预测训练何时会结束。因此，为训练设置自动通知功能非常有用。此外，当训练因意外原因中途崩溃时，也能及时收到通知，这同样很有意义。\n\n## 安装\n\n使用 `pip` 或其他等效工具进行安装。\n\n```bash\npip install knockknock\n```\n\n此代码仅在 Python >= 3.6 上进行了测试。\n\n## 使用方法\n\n该库的设计旨在无缝集成，只需对代码进行最少的修改：只需在主函数调用上方添加一个装饰器即可。返回值（如果有）也会包含在通知中。\n\n目前共有 *十二* 种通知方式：\n\n|               平台                |                                   外部贡献者                                   |\n| :-----------------------------------: | :---------------------------------------------------------------------------------------: |\n|            [电子邮件](#email)            |                                             -                                             |\n|            [Slack](#slack)            |                                             -                                             |\n|         [Telegram](#telegram)         |                                             -                                             |\n|  [Microsoft Teams](#microsoft-teams)  |                           [@noklam](https:\u002F\u002Fgithub.com\u002Fnoklam)                            |\n| [短信](\u003C#text-message-(sms)>) |                 [@abhishekkrthakur](https:\u002F\u002Fgithub.com\u002Fabhishekkrthakur)                  |\n|          [Discord](#discord)          |                         [@watkinsm](https:\u002F\u002Fgithub.com\u002Fwatkinsm)                          |\n|   [桌面通知](#desktop-notification)    | [@atakanyenel](https:\u002F\u002Fgithub.com\u002Fatakanyenel) [@eyalmazuz](https:\u002F\u002Fgithub.com\u002Feyalmazuz) |\n|           [Matrix](#matrix)           |                           [@jcklie](https:\u002F\u002Fgithub.com\u002Fjcklie)                            |\n|     [Amazon Chime](#amazon-chime)     |                     [@prabhakar267](https:\u002F\u002Fgithub.com\u002Fprabhakar267)                      |\n|         [DingTalk](#dingtalk)         |                         [@wuutiing](https:\u002F\u002Fgithub.com\u002Fwuutiing)                          |\n|       [RocketChat](#rocketchat)       |                            [@radao](https:\u002F\u002Fgithub.com\u002Fradao)                             |\n|      [企业微信](#wechat-work)      |                             [@jcyk](https:\u002F\u002Fgithub.com\u002Fjcyk)                              |\n\n\n### 电子邮件\n\n该服务依赖于 [Yagmail](https:\u002F\u002Fgithub.com\u002Fkootenpv\u002Fyagmail)，一个 GMAIL\u002FSMTP 客户端。您需要一个 Gmail 邮箱地址才能使用它（您可以在此处创建一个 [这里](https:\u002F\u002Faccounts.google.com)，免费）。建议您创建一个新的邮箱（而不是常用的邮箱），因为您需要修改账户的安全设置，以允许 Python 库通过[启用不安全的应用程序](https:\u002F\u002Fdevanswers.co\u002Fallow-less-secure-apps-access-gmail-account\u002F)访问您的邮箱。\n\n#### Python\n\n```python\nfrom knockknock import email_sender\n\n@email_sender(recipient_emails=[\"\u003Cyour_email@address.com>\", \"\u003Cyour_second_email@address.com>\"], sender_email=\"\u003Cgrandma's_email@gmail.com>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选的返回值\n```\n\n#### 命令行\n\n```bash\nknockknock email \\\n    --recipient-emails \u003Cyour_email@address.com>,\u003Cyour_second_email@address.com> \\\n    --sender-email \u003Cgrandma's_email@gmail.com> \\\n    sleep 10\n```\n\n如果未指定 `sender_email`，则会使用 `recipient_emails` 中的第一个邮箱作为发件人邮箱。\n\n请注意，运行此命令时会要求您输入发件人邮箱的密码。该密码将通过 [`keyring` Python 库](https:\u002F\u002Fpypi.org\u002Fproject\u002Fkeyring\u002F) 安全地存储在系统的密钥环服务中。\n\n\n### Slack\n\n同样，您也可以使用 Slack 接收通知。您需要获取 Slack 工作区的 [Webhook URL](https:\u002F\u002Fapi.slack.com\u002Fincoming-webhooks#create_a_webhook)，并可选择性地提供您的 [用户 ID](https:\u002F\u002Fapi.slack.com\u002Fmethods\u002Fusers.identity)（如果您想标记自己或其他人）。\n\n#### Python\n\n```python\nfrom knockknock import slack_sender\n\nwebhook_url = \"\u003Cwebhook_url_to_your_slack_room>\"\n@slack_sender(webhook_url=webhook_url, channel=\"\u003Cyour_favorite_slack_channel>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选的返回值\n```\n\n您还可以指定一个可选参数来标记特定人员：`user_mentions=[\u003Cyour_slack_id>, \u003Cgrandma's_slack_id>]`。\n\n#### 命令行\n\n```bash\nknockknock slack \\\n    --webhook-url \u003Cwebhook_url_to_your_slack_room> \\\n    --channel \u003Cyour_favorite_slack_channel> \\\n    sleep 10\n```\n\n您也可以指定一个可选参数来标记特定人员：`--user-mentions \u003Cyour_slack_id>,\u003Cgrandma's_slack_id>`。\n\n\n### Telegram\n\n您还可以使用 Telegram Messenger 接收通知。首先，您需要按照 Telegram 提供的三个步骤 [这里](https:\u002F\u002Fcore.telegram.org\u002Fbots#6-botfather) 创建自己的通知机器人，并保存您的 API 访问 `TOKEN`。\n\nTelegram 机器人比较害羞，无法发送第一条消息，因此您需要先发送一条消息。通过发送第一条消息，您可以访问 `https:\u002F\u002Fapi.telegram.org\u002Fbot\u003CYourBOTToken>\u002FgetUpdates` 来获取所需的 `chat_id`（即您的聊天室标识符），并在 `message['chat']['id']` 键下找到对应的整数值。\n\n#### Python\n\n```python\nfrom knockknock import telegram_sender\n\nCHAT_ID: int = \u003Cyour_messaging_room_id>\n@telegram_sender(token=\"\u003Cyour_api_token>\", chat_id=CHAT_ID)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选的返回值\n```\n\n#### 命令行\n\n```bash\nknockknock telegram \\\n    --token \u003Cyour_api_token> \\\n    --chat-id \u003Cyour_messaging_room_id> \\\n    sleep 10\n```\n\n### Microsoft Teams\n\n感谢 [@noklam](https:\u002F\u002Fgithub.com\u002Fnoklam)，你也可以使用 Microsoft Teams 接收通知。你需要获取你的团队频道的 [webhook URL](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fmicrosoftteams\u002Fplatform\u002Fconcepts\u002Fconnectors\u002Fconnectors-using)。\n\n#### Python\n\n```python\nfrom knockknock import teams_sender\n\n@teams_sender(token=\"\u003Cwebhook_url_to_your_teams_channel>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10)\n    return {'loss': 0.9} # 可选返回值\n```\n\n#### 命令行\n\n```bash\nknockknock teams \\\n    --webhook-url \u003Cwebhook_url_to_your_teams_channel> \\\n    sleep 10\n```\n\n你还可以指定一个可选参数来标记特定人员：`user_mentions=[\u003Cyour_teams_id>, \u003Cgrandma's_teams_id>]`。\n\n\n### 短信 (SMS)\n\n感谢 [@abhishekkrthakur](https:\u002F\u002Fgithub.com\u002Fabhishekkrthakur)，你可以使用 Twilio 发送短信通知。你需要在此处设置一个 [Twilio](www.twilio.com) 账户 [这里](https:\u002F\u002Fwww.twilio.com\u002Ftry-twilio)，这是一项收费服务，价格具有竞争力：例如在美国，获取一个新的号码和通过该服务发送一条短信分别需要花费 1.00 美元和 0.0075 美元。你需要获取 (a) 一个电话号码，(b) 你的 [account SID](https:\u002F\u002Fwww.twilio.com\u002Fdocs\u002Fglossary\u002Fwhat-is-a-sid) 和 (c) 你的 [authentification token](https:\u002F\u002Fwww.twilio.com\u002Fdocs\u002Fiam\u002Faccess-tokens)。详细信息请参阅 [这里](https:\u002F\u002Fwww.twilio.com\u002Fdocs\u002Fiam\u002Fapi\u002Faccount)。\n\n#### Python\n\n```python\nfrom knockknock import sms_sender\n\nACCOUNT_SID: str = \"\u003Cyour_account_sid>\"\nAUTH_TOKEN: str = \"\u003Cyour_auth_token>\"\n@sms_sender(account_sid=ACCOUNT_SID, auth_token=AUTH_TOKEN, recipient_number=\"\u003Crecipient's_number>\", sender_number=\"\u003Csender's_number>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10)\n    return {'loss': 0.9} # 可选返回值\n```\n\n#### 命令行\n\n```bash\nknockknock sms \\\n    --account-sid \u003Cyour_account_sid> \\\n    --auth-token \u003Cyour_account_auth_token> \\\n    --recipient-number \u003Crecipient_number> \\\n    --sender-number \u003Csender_number>\n    sleep 10\n```\n\n\n### Discord\n\n感谢 [@watkinsm](https:\u002F\u002Fgithub.com\u002Fwatkinsm)，你也可以使用 Discord 接收通知。你只需要获取你的 Discord 频道的 [webhook URL](https:\u002F\u002Fsupport.discordapp.com\u002Fhc\u002Fen-us\u002Farticles\u002F228383668-Intro-to-Webhooks)。\n\n#### Python\n\n```python\nfrom knockknock import discord_sender\n\nwebhook_url = \"\u003Cwebhook_url_to_your_discord_channel>\"\n@discord_sender(webhook_url=webhook_url)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选返回值\n```\n\n#### 命令行\n\n```bash\nknockknock discord \\\n    --webhook-url \u003Cwebhook_url_to_your_discord_channel> \\\n    sleep 10\n```\n\n\n### 桌面通知\n\n你也可以通过桌面通知接收提醒。目前仅适用于 MacOS、Linux 和 Windows 10。\n\n对于 Linux，它使用 notify-send 命令，该命令依赖于 libnotify。要使用 libnotify，你需要安装一个通知服务器。Cinnamon、Deepin、Enlightenment、GNOME、GNOME Flashback 和 KDE Plasma 都有自己的通知显示实现。在其他桌面环境中，你需要通过你的窗口管理器或桌面环境的“自动启动”选项来启动通知服务器。\n\n#### Python\n\n```python\nfrom knockknock import desktop_sender\n\n@desktop_sender(title=\"Knockknock Desktop Notifier\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {\"loss\": 0.9}\n```\n\n#### 命令行\n\n```bash\nknockknock desktop \\\n    --title 'Knockknock Desktop Notifier' \\\n    sleep 2\n```\n\n\n### Matrix\n\n感谢 [@jcklie](https:\u002F\u002Fgithub.com\u002Fjcklie)，你可以通过 [Matrix](https:\u002F\u002Fmatrix.org\u002F) 发送通知。homeserver 是你将发送消息的用户所注册的服务器。不要忘记 URL 的协议（`http` 或 `https`）。\n\n你需要获取机器人或你自己的用户的访问令牌。最简单的方法是在 Riot 中查看，进入设置中的“帮助与关于”，在底部可以看到：“访问令牌：\u003C点击以显示>”。你还需要指定一个房间别名，用于发送消息。要在 Riot 中获取别名，创建一个你想使用的房间，然后在“房间地址”中打开房间设置并添加一个别名。\n\n#### Python\n\n```python\nfrom knockknock import matrix_sender\n\nHOMESERVER = \"\u003Curl_to_your_home_server>\" # 例如 https:\u002F\u002Fmatrix.org\nTOKEN = \"\u003Cyour_auth_token>\"              # 例如 WiTyGizlr8ntvBXdFfZLctyY\nROOM = \"\u003Croom_alias\"                     # 例如 #knockknock:matrix.org\n\n@matrix_sender(homeserver=HOMESERVER, token=TOKEN, room=ROOM)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选返回值\n```\n\n#### 命令行\n\n```bash\nknockknock matrix \\\n    --homeserver \u003Chomeserver> \\\n    --token \u003Ctoken> \\\n    --room \u003Croom> \\\n    sleep 10\n```\n\n\n### Amazon Chime\n\n感谢 [@prabhakar267](https:\u002F\u002Fgithub.com\u002Fprabhakar267)，你也可以使用 Amazon Chime 接收通知。你需要获取你的 Chime 会议室的 [webhook URL](https:\u002F\u002Fdocs.aws.amazon.com\u002Fchime\u002Flatest\u002Fdg\u002Fwebhooks.html)。\n\n#### Python\n\n```python\nfrom knockknock import chime_sender\n\n@chime_sender(webhook_url=\"\u003Cwebhook_url_to_your_chime_room>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10)\n    return {'loss': 0.9} # 可选返回值\n```\n\n#### 命令行\n\n```bash\nknockknock chime \\\n    --webhook-url \u003Cwebhook_url_to_your_chime_room> \\\n    sleep 10\n```\n\n你还可以指定一个可选参数来标记特定人员：`user_mentions=[\u003Cyour_alias>, \u003Cgrandma's_alias>]`。\n\n\n### 钉钉\n\n现在也支持钉钉通知，感谢 [@wuutiing](https:\u002F\u002Fgithub.com\u002Fwuutiing)。只需提供钉钉聊天机器人 webhook URL 和密钥\u002F关键词（至少在创建聊天机器人时设置其中一个），你的通知就会发送到该聊天室中的任何一人。\n\n#### Python\n\n```python\nfrom knockknock import dingtalk_sender\n\nwebhook_url = \"\u003Cwebhook_url_to_your_dingtalk_chatroom_robot>\"\n@dingtalk_sender(webhook_url=webhook_url, secret=\"\u003Cyour_robot_secret_if_set>\", keywords=[\"\u003Clist_of_keywords_if_set>\"])\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选返回值\n```\n\n#### 命令行\n\n```bash\nknockknock dingtalk \\\n    --webhook-url \u003Cwebhook_url_to_your_dingtalk_chatroom_robot> \\\n    --secret \u003Cyour_robot_secret_if_set> \\\n    sleep 10\n```\n\n你还可以指定一个可选参数来标记特定人员：`user_mentions=[\"\u003Clist_of_phonenumbers_who_you_want_to_tag>\"]`。\n\n### RocketChat\n\n您可以使用 [RocketChat](https:\u002F\u002Frocket.chat\u002F) 接收通知。在发送通知之前，您需要准备以下内容：\n\n- 一个 RocketChat 服务器，例如 rocketchat.yourcompany.com\n- 一个 RocketChat 用户 ID（您可以在下一步创建个人访问令牌时查看您的用户 ID）\n- 一个 RocketChat 个人访问令牌（[请按照此指南创建](https:\u002F\u002Frocket.chat\u002Fdocs\u002Fdeveloper-guides\u002Frest-api\u002Fpersonal-access-tokens\u002F)）\n- 一个 RocketChat 频道\n\n#### Python\n\n```python\nfrom knockknock import rocketchat_sender\n\n@rocketchat_sender(\n    rocketchat_server_url=\"\u003C您的 RocketChat 服务器地址>\",\n    rocketchat_user_id=\"\u003C您的 RocketChat 用户 ID>\",\n    rocketchat_auth_token=\"\u003C您的 RocketChat 认证令牌>\",\n    channel=\"\u003C频道名称>\")\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选返回值\n```\n\n您还可以指定两个可选参数：\n\n- 标记特定用户：`user_mentions=[\u003C您的用户名>, \u003C奶奶的用户名>]`\n- 使用通知别名：`alias=\"我的别名\"`\n\n#### 命令行\n\n```bash\nknockknock rocketchat \\\n    --rocketchat-server-url \u003C您的 RocketChat 服务器地址> \\\n    --rocketchat-user-id \u003C您的 RocketChat 用户 ID> \\\n    --rocketchat-auth-token \u003C您的 RocketChat 认证令牌> \\\n    --channel \u003C频道名称> \\\n    sleep 10\n```\n\n\n### 微信企业号\n\n感谢 [@jcyk](https:\u002F\u002Fgithub.com\u002Fjcyk) 的支持，现在也支持微信企业号了。只需提供微信企业号聊天室机器人的 Webhook 地址，您的通知就会发送到该聊天室中的所有人。\n\n#### Python\n\n```python\nfrom knockknock import wechat_sender\n\nwebhook_url = \"\u003C您的微信企业号聊天室机器人 Webhook 地址>\"\n@wechat_sender(webhook_url=webhook_url)\ndef train_your_nicest_model(your_nicest_parameters):\n    import time\n    time.sleep(10000)\n    return {'loss': 0.9} # 可选返回值\n```\n\n#### 命令行\n\n```bash\nknockknock wechat \\\n    --webhook-url \u003C您的微信企业号聊天室机器人 Webhook 地址> \\\n    sleep 10\n```\n\n您还可以指定一个可选参数来标记特定人员：`user-mentions=[\"\u003C您想要标记的用户ID列表>\"]` 和\u002F或 `user-mentions-mobile=[\"\u003C您想要标记的手机号码列表>\"]`。\n\n\n## 关于分布式训练的说明\n\n在使用分布式训练时，每个 GPU 都会通过本地 rank 变量绑定到其对应的进程。由于 knockknock 是在进程级别工作的，如果您使用 8 个 GPU，那么在训练开始和结束时都会收到 8 条通知……为了解决这个问题，除了出现错误的情况外，只有主进程可以发送通知，这样您就只会分别在训练开始和结束时各收到一条通知。\n\n**注意：** _在 PyTorch 中，`torch.distributed.launch` 的启动会为每个进程设置一个 RANK 环境变量（详见 [此处](https:\u002F\u002Fgithub.com\u002Fpytorch\u002Fpytorch\u002Fblob\u002Fmaster\u002Ftorch\u002Fdistributed\u002Flaunch.py#L211)）。这个变量用于识别主进程，目前这也是我想到的唯一简单方法。遗憾的是，这种方法并不适用于所有平台，但我非常乐意在 issue 或 PR 中与大家讨论更智能、更好的分布式训练处理方式。_","# Knock Knock 快速上手指南\n\nKnock Knock 是一个轻量级的 Python 库，旨在通过仅需两行代码即可在深度学习模型训练完成或意外崩溃时发送通知。它支持邮件、Slack、Telegram、钉钉、企业微信等十余种通知渠道。\n\n## 环境准备\n\n- **操作系统**：Linux, macOS, Windows 10+\n- **Python 版本**：>= 3.6\n- **前置依赖**：无特殊系统依赖（桌面通知在 Linux 下需确保已安装 `libnotify` 及相关通知服务）\n\n## 安装步骤\n\n使用 pip 进行安装。国内用户推荐使用清华或阿里镜像源以加速下载：\n\n```bash\npip install knockknock -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n或者使用默认源：\n\n```bash\npip install knockknock\n```\n\n## 基本使用\n\nKnock Knock 的核心用法是通过**装饰器**包裹你的主训练函数。以下以最常用的 **Email** 和 **命令行模式** 为例。\n\n### 方式一：Python 装饰器（推荐）\n\n在训练脚本中导入对应的发送器，并将其作为装饰器添加到主函数上方。\n\n**示例：发送邮件通知**\n\n```python\nfrom knockknock import email_sender\n\n@email_sender(\n    recipient_emails=[\"your_email@address.com\"], \n    sender_email=\"sender_email@gmail.com\"\n)\ndef train_your_model():\n    import time\n    # 模拟训练过程\n    time.sleep(10) \n    return {'loss': 0.9}  # 返回值也会包含在通知中\n\nif __name__ == \"__main__\":\n    train_your_model()\n```\n\n*注意：首次运行邮件通知时，程序会提示输入发件人邮箱密码，密码将安全存储在系统密钥环中。若使用 Gmail，需开启“允许不够安全的应用”访问权限。*\n\n### 方式二：命令行模式\n\n无需修改代码，直接在终端命令前加上 `knockknock [渠道] [参数]` 即可监控任意命令的执行状态。\n\n**示例：监控一个耗时命令**\n\n```bash\nknockknock email \\\n    --recipient-emails your_email@address.com \\\n    --sender-email sender_email@gmail.com \\\n    python train.py\n```\n\n### 支持的通知渠道\n\n除了 Email，库还支持以下渠道（使用方法类似，只需更换导入模块或命令行关键字）：\n\n| 渠道 | Python 模块 | 命令行关键字 | 备注 |\n| :--- | :--- | :--- | :--- |\n| **Slack** | `slack_sender` | `slack` | 需 Webhook URL |\n| **Telegram** | `telegram_sender` | `telegram` | 需 Bot Token 和 Chat ID |\n| **钉钉** | `dingtalk_sender` | `dingtalk` | 需 Webhook URL (国内常用) |\n| **企业微信** | `wechat_work_sender` | `wechat-work` | 需 Webhook Key (国内常用) |\n| **Microsoft Teams** | `teams_sender` | `teams` | 需 Webhook URL |\n| **短信 (SMS)** | `sms_sender` | `sms` | 需 Twilio 账号 (付费) |\n| **Discord** | `discord_sender` | `discord` | 需 Webhook URL |\n| **桌面通知** | `desktop_sender` | `desktop` | 仅限本地弹窗 |\n| **Matrix** | `matrix_sender` | `matrix` | 需 Homeserver 和 Token |\n| **Amazon Chime** | `chime_sender` | `chime` | 需 Webhook URL |\n| **RocketChat** | `rocketchat_sender` | `rocketchat` | 需 Webhook URL |\n\n具体各渠道的 Token 或 Webhook 获取方式，请参考官方文档对应章节。","某算法工程师正在训练一个需要运行 12 小时的大型语言模型微调任务，期间无法时刻守在屏幕前监控进度。\n\n### 没有 knockknock 时\n- **无效等待与焦虑**：不敢离开座位去休息或开会，必须频繁手动刷新日志查看是否结束，精神高度紧张。\n- **意外崩溃无感知**：若训练在第 10 小时因显存溢出意外中断，由于无人值守，直到第二天上班才发现，浪费了整整一晚的算力资源。\n- **时间估算困难**：由于使用了早停（Early Stopping）策略，实际结束时间难以精确预测，导致无法合理安排后续工作或生活节奏。\n- **结果获取滞后**：训练完成后无法第一时间获取评估指标，必须登录服务器查看日志文件才能确认模型效果，流程繁琐。\n\n### 使用 knockknock 后\n- **解放注意力**：只需在训练函数前添加两行装饰器代码，即可安心去吃饭、睡觉或处理其他工作，无需时刻盯着进度条。\n- **实时故障报警**：一旦训练过程中发生崩溃，knockknock 会立即通过邮件、Slack 或钉钉发送报错通知，确保能立刻介入修复，避免算力空转。\n- **精准掌握时机**：无论训练因达到最大轮次还是触发早停而结束，都会收到即时提醒，完美衔接后续的实验部署或数据分析工作。\n- **自动汇报结果**：通知消息中直接包含函数的返回值（如最终准确率或 Loss），无需额外登录服务器查询，核心数据一目了然。\n\nknockknock 用极简的代码接入，将被动且焦虑的“守株待兔”式训练监控，转变为高效、安心的自动化闭环管理。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhuggingface_knockknock_caf9daa0.png","huggingface","Hugging Face","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fhuggingface_90da21a4.png","The AI community building the future.",null,"https:\u002F\u002Fhuggingface.co\u002F","https:\u002F\u002Fgithub.com\u002Fhuggingface",[80],{"name":81,"color":82,"percentage":83},"Python","#3572A5",100,2826,227,"2026-04-07T05:40:00","MIT","Linux, macOS, Windows 10","未说明",{"notes":91,"python":92,"dependencies":93},"该工具是一个轻量级通知库，本身无 GPU 或高内存需求。但在使用特定功能时有额外要求：1. 邮件通知需配置 Gmail 账户并开启“允许不够安全的应用”；2. 短信通知需付费注册 Twilio 账户；3. 桌面通知在 Linux 上需安装并运行 libnotify 兼容的通知服务器；4. 其他平台（Slack, Telegram, Teams 等）均需预先获取对应的 Webhook URL、Token 或 Chat ID。",">=3.6",[94,95],"yagmail","keyring",[15,35,14],[98,99,100,101,102,103,104,105,106,107,108],"machine-learning","natural-language-processing","nlproc","nlp","computer-vision","cv","python","python36","deep-learning","neural-networks","train","2026-03-27T02:49:30.150509","2026-04-12T08:08:05.031952",[112,117,122,127,132,137,142],{"id":113,"question_zh":114,"answer_zh":115,"source_url":116},30418,"安装后出现 'ModuleNotFoundError: No module named knockknock' 错误怎么办？","这通常是由于 Python 或 pip 版本冲突导致的。建议在一个全新的干净环境（如 virtualenv 或 conda 环境）中重新尝试安装。如果问题依旧，请检查是否同时在 python2 和 python3 中进行了安装，确保使用正确的 pip 版本对应相应的 Python 环境。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fissues\u002F28",{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},30419,"任务完成后为什么还需要输入密码？如何实现无人值守的通知？","这是因为库默认使用系统密钥环（keyring）存储凭证，导致在脚本运行时仍需交互输入密码。解决方法是禁用 keyring：运行 `keyring --disable`。禁用后，首次运行时脚本会提示输入邮箱密码并询问是否保存，选择 'y' 保存后，后续运行（包括任务开始和结束发送两封邮件时）将不再需要手动输入密码，从而实现无人值守通知。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fissues\u002F6",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},30420,"如何使用 Conda 安装 knockknock？","维护者已上传了 `osx-64` 包，Mac 用户可以直接尝试通过 conda 安装。如果 conda 安装遇到困难（因为 conda 支持不如 pip 平滑），可以使用备用方案：下载源码后运行 `python setup.py install` 进行安装。注意这种方式安装的包不会被 conda 包管理器追踪，但可以正常使用库的功能。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fissues\u002F4",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},30421,"使用 email_sender 时遇到 'socket.gaierror: Temporary failure in name resolution' 错误如何解决？","该错误通常表示底层的邮件发送库（yagmail）无法解析或访问指定的 Gmail 地址。首先请确认是否在 Gmail 设置中开启了“允许安全性较低的应用”（Less secure apps）。如果问题仍然存在，建议尝试其他集成方式（如 Telegram 或 Slack sender）来排查是否是特定于邮件服务的问题。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fissues\u002F12",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},30422,"在 Mac 上设置开发环境时，安装 'win10toast' 依赖失败怎么办？","`win10toast` 是仅用于 Windows 桌面通知的依赖项，在 Mac 或 Linux 上不需要安装。如果您在克隆仓库后遇到此错误，请确保拉取了最新的代码（`git pull`），因为维护者已在最新版本中移除了非 Windows 平台对该依赖的强制要求。如果您不是开发者只是普通用户，直接通过 pip 安装发布版即可，无需手动处理此依赖。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fissues\u002F45",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},30423,"如何在 email_sender 中设置多个收件人邮箱？","该功能已被支持并合并到主分支（PR #23）。您可以在 `recipient_email` 参数中传入一个包含多个邮箱地址的列表，例如：`recipient_email=[\"user1@example.com\", \"user2@example.com\"]`，即可同时向多位收件人发送通知。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fissues\u002F22",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},30424,"是否支持 macOS 的桌面弹窗通知？","是的，项目已支持 macOS 桌面通知。您可以使用 `@desktop_sender()` 装饰器来实现。当脚本运行结束时，会在屏幕右上角弹出通知。该功能通过检测操作系统类型自动适配，目前主要支持 macOS，未来可能扩展至 Windows 和 Linux。","https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fknockknock\u002Fissues\u002F26",[]]