Skip to content

Tin/update write artifact - #1114

Open
Tintinator wants to merge 5 commits into
taskcluster:mainfrom
Tintinator:tin/update-write_artifact
Open

Tintinator wants to merge 5 commits into
taskcluster:mainfrom
Tintinator:tin/update-write_artifact

Conversation

@Tintinator

Copy link
Copy Markdown

updated write_artifacts to handle .json.gz and .mm files

this is done as a part of the effort to merge actions logic between gecko_taskgraph and taskgraph.

@Tintinator
Tintinator requested a review from a team as a code owner November 17, 2026 07:24
@Tintinator
Tintinator requested a review from ahal November 17, 2026 07:24
Comment thread src/taskgraph/decision.py Outdated

with gzip.open(path, "wb") as f:
f.write(json.dumps(data)) # type: ignore
if filename.endsWith(".json.gz"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/endsWith/endswith

@ahal
ahal self-requested a review November 19, 2026 21:39

@ahal ahal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed review!

This patch is technically correct, but there are a couple more changes I'd like before accepting it.

Comment thread src/taskgraph/decision.py
f.write(json.dumps(data).encode("utf-8")) # type: ignore
else:
f.write(json.dumps(data)) # type: ignore
elif filename.endswith(".mm"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .mm is a mermaid diagram and specific to gecko_taskgraph. Instead of checking specifically for this extension, let's just write the data as long as it's a string. So change this to elif isinstance(data, str):

Comment thread src/taskgraph/decision.py
if filename.endswith(".json.gz"):
f.write(json.dumps(data).encode("utf-8")) # type: ignore
else:
f.write(json.dumps(data)) # type: ignore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has actually been broken this whole time. It's trying to write a str to a file opened in binary mode. I suspect it was regressed way back when we were migrating from Python 2 -> 3.

So you can simplify this and fix the bug by doing something like:

elif filename.endswith(".gz"):
    import gzip  # noqa: PLC0415

    with gzip.open(path, "wt", encoding="utf-8") as f:
        json.dump(data, f)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants