This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from collections import namedtuple | |
from typing import Tuple, List | |
GH_GET_REPO_ID = """ | |
query ($owner: String = "pytorch", $name: String = "pytorch") { | |
repository(name: $name, owner: $owner) { | |
id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
MPS_PROJECT_NUMBER = 26 | |
GH_GET_PROJECT_ID = """ | |
query ($owner: String = "pytorch", $name: String = "pytorch", $number: Int = 26) { | |
repository(name: $name, owner: $owner) { | |
projectV2(number: $number) { | |
id | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Very restricted unpickler | |
# Based of https://github.com/python/cpython/blob/main/Lib/pickle.py | |
# Expected to be useful for loading PyTorch model weights | |
# For example: | |
# data = urllib.request.urlopen('https://download.pytorch.org/models/resnet50-0676ba61.pth').read() | |
# buf = io.BytesIO(data) | |
# weights = torch.load(buf, pickle_module=WeightsUnpickler) | |
import sys | |
from sys import maxsize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
GH_GET_VIEWER_LOGIN = """ | |
query { | |
viewer { | |
login | |
} | |
} | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile me as | |
// clang++ query_metal_devices.mm -framework Metal -framework Foundation | |
#include <Metal/Metal.h> | |
int main() { | |
@autoreleasepool { | |
NSArray* devices = [MTLCopyAllDevices() autorelease]; | |
NSLog(@"Metal device count %lu", devices.count); | |
for (unsigned long i = 0 ; i < devices.count ; i++) { | |
id<MTLDevice> device = devices[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Trying to use graphQL to fetch all commits associated with PR https://github.com/pytorch/pytorch/pull/77471 | |
# Expect to get 700+ commits for for some reason pagination ends after first 250 | |
# Needs valid PAT passed via GITHUB_TOKEN environment variable | |
GH_GET_COMMITS = """ | |
query($cursor: String) { | |
repository(owner: "pytorch", name: "pytorch") { | |
pullRequest(number: 77471) { | |
commits(first: 100, after: $cursor) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
repository(name: "pytorch", owner: "pytorch") { | |
object(oid: "7dd08230117f4fa8bb82b3524e90fb00340198c7") { | |
... on Commit { | |
checkSuites(first: 100, filterBy: {appId: 15368}) { | |
nodes { | |
workflowRun { | |
workflow { | |
name | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
repository(owner: "pytorch", name: "pytorch") { | |
pullRequest(number: 68111) { | |
closed | |
isCrossRepository | |
author { | |
login | |
} | |
title | |
body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Author of https://github.com/pytorch/pytorch/pull/71735 is me (malfet) | |
# And if executed with my PAT it will return my association as "MEMBER" | |
# But if executed by somebody outside of org, it will say that association is "CONTRIBUTOR" | |
# Instead of getting PAT, one can simply execute the query at https://docs.github.com/en/graphql/overview/explorer | |
GH_GET_ASSOCIATION = """ | |
query { | |
repository(owner: "pytorch", name: "pytorch") { | |
pullRequest(number: 71735) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Print default branch for public repos in pytorch org | |
# Requires github token | |
from typing import Any, Dict | |
GH_SEARCH_REPO_REQ = """ | |
query($cursor: String) { | |
search(type: REPOSITORY, query: "org:pytorch", first: 100, after: $cursor) { | |
nodes { | |
... on Repository { |