diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..271797a --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +Biswaroop Bhattacharjee diff --git a/_config.yml b/_config.yml index 68aaaae..a449d9b 100644 --- a/_config.yml +++ b/_config.yml @@ -49,6 +49,7 @@ sphinx: extra_extensions: - sphinxemoji.sphinxemoji - sphinx_last_updated_by_git + - committers config: html_js_files: - [https://analytics.prem.ninja/js/script.js, {defer: defer, data-domain: book.premai.io}] diff --git a/committers.py b/committers.py new file mode 100644 index 0000000..a599df7 --- /dev/null +++ b/committers.py @@ -0,0 +1,89 @@ +"""Print list of Git committer names. + +Example MyST usage (HTML only): + + ```{committers} file_path.md + ``` +""" +import json +import os +import re +import subprocess +from collections import Counter +from datetime import timedelta +from functools import cache +from time import ctime, time + +from docutils import nodes +from docutils.parsers.rst import Directive, directives +from sphinx.application import Sphinx + +__version__ = '0.0.0' + + +@cache +def gh_user(email) -> str | None: + headers = [ + '--header', 'Accept: application/vnd.github+json', + '--header', 'X-GitHub-Api-Version: 2022-11-28'] + if (token := os.environ.get("GITHUB_TOKEN", os.environ.get("GH_TOKEN", ""))): + headers.extend(['--header', f'Authorization: Bearer {token}']) + for cmd in ( + ['gh', 'api'] + headers + [f'search/users?q={email}+in:email'], + ['curl'] + headers + ['-fsSL', f'https://api.github.com/search/users?q={email}+in:email'], + ['wget'] + headers + ['-qO', '-', f'https://api.github.com/search/users?q={email}+in:email'] + ): + try: + user_info = subprocess.check_output(cmd).decode('utf-8').strip() + except (subprocess.CalledProcessError, FileNotFoundError): + pass + else: + try: + return json.loads(user_info)['items'][0]['login'] + except (KeyError, IndexError): + return + + +class committers_node(nodes.General, nodes.Element): + pass + + +def visit_committers_html(self, node): + self.body.append(self.starttag(node, 'div')) + self.body.append("Authors: ") + self.body.append(", ".join(f'{name}' for name, href in node['authors'])) + + +def depart_committers_html(self, node): + self.body.append('') + + +class Committers(Directive): + has_content = True + required_arguments = 1 + optional_arguments = 0 + final_argument_whitespace = True + option_spec = {'class': directives.class_option, 'name': directives.unchanged} + _node = None + + def run(self): + blame = subprocess.check_output([ + 'git', 'blame', '--line-porcelain', '-C2', '-M2', '--'] + self.arguments + ).decode('utf-8').strip() + authors = Counter(re.findall("^author (.*)\nauthor-mail <(.*)>", blame, flags=re.MULTILINE)) + total_loc = authors.total() + auths = [] + for (name, email), loc in authors.most_common(): + if loc / total_loc < 0.05: + break + if (user := gh_user(email)): + auths.append((name, f"https://github.com/{user}")) + else: + auths.append((name, f"mailto:{email}")) + return [committers_node(authors=auths)] + + +def setup(app: Sphinx): + app.add_node(committers_node, html=(visit_committers_html, depart_committers_html)) + app.add_directive("committers", Committers) + return {'version': __version__, 'parallel_read_safe': True} diff --git a/desktop-apps.md b/desktop-apps.md index e8718f3..2801ebb 100644 --- a/desktop-apps.md +++ b/desktop-apps.md @@ -10,3 +10,6 @@ See also: ## GPT4All UI {{ comments }} + +```{committers} desktop-apps.md +``` diff --git a/eval-datasets.md b/eval-datasets.md index 5b7f5eb..26bded9 100644 --- a/eval-datasets.md +++ b/eval-datasets.md @@ -23,3 +23,6 @@ probably put short definition in [](glossary)? ## Reinforcement Learning for a Chat-based LLM {{ comments }} + +```{committers} eval-datasets.md +``` diff --git a/fine-tuning.md b/fine-tuning.md index a3ba10f..b04659c 100644 --- a/fine-tuning.md +++ b/fine-tuning.md @@ -55,3 +55,6 @@ Falcon | ## Code Generators {{ comments }} + +```{committers} fine-tuning.md +``` diff --git a/hardware.md b/hardware.md index 28d5b75..1b31086 100644 --- a/hardware.md +++ b/hardware.md @@ -20,3 +20,6 @@ See also: + LLM-specific advice: https://gpus.llm-utils.org/cloud-gpu-guide/#which-gpu-cloud-should-i-use {{ comments }} + +```{committers} hardware.md +``` diff --git a/licences.md b/licences.md index 5b20104..d983f46 100644 --- a/licences.md +++ b/licences.md @@ -175,3 +175,6 @@ In the long term, we look forward to the outcomes of the US cases and EU proposa (licences-comments)= {{ comments }} + +```{committers} licences.md +``` diff --git a/mlops-engines.md b/mlops-engines.md index 9b374ca..1a8188c 100644 --- a/mlops-engines.md +++ b/mlops-engines.md @@ -27,3 +27,6 @@ See also https://onnxruntime.ai/docs/execution-providers ### Apache TVM {{ comments }} + +```{committers} mlops-engines.md +``` diff --git a/model-formats.md b/model-formats.md index 9163566..f197a32 100644 --- a/model-formats.md +++ b/model-formats.md @@ -11,3 +11,6 @@ See also: ## TVM {{ comments }} + +```{committers} model-formats.md +``` diff --git a/models.md b/models.md index 845e219..4b9db5e 100644 --- a/models.md +++ b/models.md @@ -13,3 +13,6 @@ See also: - {cite}`golden-age-os-end` {{ comments }} + +```{committers} models.md +``` diff --git a/sdk.md b/sdk.md index a603966..a861c5c 100644 --- a/sdk.md +++ b/sdk.md @@ -9,3 +9,6 @@ See also: https://github.com/huggingface/transformers/blob/main/awesome-transfor ## Haystack {{ comments }} + +```{committers} sdk.md +``` diff --git a/uncensored-models.md b/uncensored-models.md index d4bf251..811d22b 100644 --- a/uncensored-models.md +++ b/uncensored-models.md @@ -5,3 +5,6 @@ FraudGPT, PoisonGPT "Cybercriminals train AI chatbots for phishing, malware attacks" (WormGPT: ChatGPT clone trained on malware-focused data, new: FraudGPT, coming soon: Bard-based version) https://www.bleepingcomputer.com/news/security/cybercriminals-train-ai-chatbots-for-phishing-malware-attacks {{ comments }} + +```{committers} uncensored-models.md +``` diff --git a/vector-stores.md b/vector-stores.md index 3de5c70..25c3896 100644 --- a/vector-stores.md +++ b/vector-stores.md @@ -11,3 +11,6 @@ ## Chroma {{ comments }} + +```{committers} vector-stores.md +```