Skip to content

Instantly share code, notes, and snippets.

@malfet
malfet / get_comits.py
Last active June 8, 2022 00:11
Trying to fetch all commit PRs using GraphQL API
#!/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) {
@malfet
malfet / get_mac_annotations.js
Last active March 22, 2022 21:05
GQL to query annotations
{
repository(name: "pytorch", owner: "pytorch") {
object(oid: "7dd08230117f4fa8bb82b3524e90fb00340198c7") {
... on Commit {
checkSuites(first: 100, filterBy: {appId: 15368}) {
nodes {
workflowRun {
workflow {
name
}
@malfet
malfet / gist:9b93bc7eeddeaf1d84546efc4f0c577f
Last active March 25, 2022 01:17
GraphQL query causing HTTP/502
query {
repository(owner: "pytorch", name: "pytorch") {
pullRequest(number: 68111) {
closed
isCrossRepository
author {
login
}
title
body
@malfet
malfet / gh_association_curiosities.py
Created January 26, 2022 17:07
Querying author association from github
#!/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) {
@malfet
malfet / get_default_branch.py
Created January 19, 2022 17:32
Print default branches for public repos in pytorch org
#!/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 {
% curl -L https://github.com/pytorch/pytorch/pull/69840.patch|diffstat
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 143 100 143 0 0 459 0 --:--:-- --:--:-- --:--:-- 468
100 7148 0 7148 0 0 11172 0 --:--:-- --:--:-- --:--:-- 11172
aten/src/ATen/templates/RegisterBackendSelect.cpp | 27 ++++++++++++++-------------
aten/src/ATen/templates/RegisterSchema.cpp | 16 +---------------
tools/codegen/gen.py | 40 +++++++++++++++++++++++-----------------
3 files changed, 38 insertions(+), 45 deletions(-)
% curl -L https://github.com/pytorch/pytorch/pull/69840.diff|diffstat
@malfet
malfet / torch_query_memory.py
Created November 24, 2021 01:46
Query PyTorch memory utilisation
#!/usr/bin/env python3
import os
from subprocess import check_output
def get_pmem():
pmem = check_output(["sh", "-c", f"pmap -d {os.getpid()}|tail -n 1"], encoding="latin1").split()[3]
return pmem
def get_gpumem():
@malfet
malfet / hello.cu
Last active November 24, 2021 21:05
CUDA Hello world
#include <stdio.h>
__global__ void kernel() {
printf("Hello World of CUDA %d\n", threadIdx.x);
}
int main() {
kernel<<<1,1>>>();
return cudaDeviceSynchronize();
}
@malfet
malfet / gist:175d76815eebf8b2f19005cb80105b45
Created November 1, 2021 17:44
pytorch.github.io broken links
URL `resources/fonts/dejavu.css'
Parent URL file:///home/nshulga/git/pytorch.github.io/javadoc/stylesheet.css, line 3, col 12
Real URL file:///home/nshulga/git/pytorch.github.io/javadoc/resources/fonts/dejavu.css
Result Error: URLError: <urlopen error [Errno 2] No such file or directory: '/home/nshulga/git/pytorch.github.io/javadoc/resources/fonts/dejavu.css'>
URL `../fonts/FreightSans/freight-sans-bold.woff'
Parent URL file:///home/nshulga/git/pytorch.github.io/assets/main.css, line 1, col 147264
Real URL file:///home/nshulga/git/pytorch.github.io/fonts/FreightSans/freight-sans-bold.woff
Result Error: URLError: <urlopen error [Errno 2] No such file or directory: '/home/nshulga/git/pytorch.github.io/fonts/FreightSans/freight-sans-bold.woff'>
@malfet
malfet / whatsmyname.cpp
Created October 7, 2021 16:41
Prints name of the template argument
#include <iostream>
#include <string>
template<typename T>
struct WhatsMyName {
WhatsMyName() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
}
};