-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the comment watermark format #1076
Comments
Parsing data in watermarksSimple use case of embedding machine-readable metrics into reports; hacky1 but functional. import base64
import commonmark
import json
WATERMARK = "https://cml.dev/9b0e332381649d87112c181dae1568640ea055b3100e5253d86410d276db8af9/pixel.gif"
def extract_metrics(report: str) -> any:
for node, _ in commonmark.Parser().parse(report).walker():
if node.t == "image" and node.destination == WATERMARK:
return json.loads(base64.b64decode(node.first_child.literal))
if __name__ == "__main__":
with open("report.md", "r") as report:
print(extract_metrics(report.read())) Footnotes
|
🤢 |
We can also use Unicode zero-width watermarks: 🤔 |
Looks like there are several ways to do this:
Also, I think it looks a bit amateurish to include resources hosted by github (the watermark svg) - we should at least host it ourselves. |
Playing devil's advocate: hosting it on GitHub is a good guarantee it can't be used for tracking. 🤷🏼♂️ |
That's putting a lot of faith in github :) |
Option Footnotes |
Option |
|
|
|
Watermarks are invisible strings inserted on CML comments1 so they can be differentiated from comments created by users. Our current watermark format is all but uniquely identifiable, and should probably be updated.
cml/src/cml.js
Line 181 in 7bd9257
Note that watermarks use a blank image instead of an HTML comment, because not all forges support the latter in their respective flavours of Markdown.
Proposal
Use the image description to store arbitrary data encoded as Base64 (e.g. useful for live metrics) and the image link to point to an invisible, tiny image in a static host of our choice.
Precursors
cml publish
withcml send-comment
#1026 (comment)Footnotes
E.g. created by running
cml send-comment
↩The text was updated successfully, but these errors were encountered: