This file contains hidden or 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
# /// script | |
# requires-python = "==3.10" | |
# dependencies = [ | |
# "pydantic", | |
# "openai", | |
# ] | |
# /// | |
# ruff: noqa: T201 | |
""" | |
How to run (https://gist.github.com/harupy/bc281c07d1a2d0678f97cf519aa81131) |
This file contains hidden or 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
import ast | |
from pathlib import Path | |
import subprocess | |
from typing import List, Dict | |
from dataclasses import dataclass | |
def line_no_to_offset(lines: List[str]) -> Dict[int, int]: |
This file contains hidden or 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
services: | |
mysql: | |
image: mysql | |
restart: always | |
environment: | |
MYSQL_ROOT_PASSWORD: root-password | |
MYSQL_DATABASE: mlflowdb | |
MYSQL_USER: mlflowuser | |
MYSQL_PASSWORD: mlflowpassword | |
command: mysqld --default-authentication-plugin=mysql_native_password |
This file contains hidden or 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
from __future__ import annotations | |
import ast | |
import os | |
import random | |
import subprocess | |
import textwrap | |
import openai |
This file contains hidden or 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
b""" | |
{ | |
"id": "chatcmpl-7lG2usbCnpQIBmid2fGZjsT9Wymh4", | |
"object": "chat.completion.chunk", | |
"created": 1691497452, | |
"model": "gpt-3.5-turbo-0613", | |
"choices": [ | |
{ | |
"index": 0, | |
"delta": {"content": " set"}, |
This file contains hidden or 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
import boto3 | |
import requests | |
import uuid | |
import tempfile | |
from pathlib import Path | |
import sys | |
with tempfile.TemporaryDirectory() as tmpdir: | |
# Create a 500MB file |
This file contains hidden or 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
import mlflow | |
from sklearn.linear_model import LogisticRegression | |
from pathlib import Path | |
import tempfile | |
with mlflow.start_run(): | |
mi = mlflow.sklearn.log_model(LogisticRegression(), "model") | |
client = mlflow.MlflowClient() | |
with tempfile.TemporaryDirectory() as tmpdir: |
This file contains hidden or 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
import libcst as cst | |
import pathlib | |
import argparse | |
import difflib | |
class AssertMethodTransformer(cst.CSTTransformer): | |
@staticmethod | |
def is_unittest_assert_method(node: cst.Call, name: str) -> bool: | |
return ( |
This file contains hidden or 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
import libcst as cst | |
import pathlib | |
import argparse | |
import difflib | |
class AssertMethodTransformer(cst.CSTTransformer): | |
@staticmethod | |
def is_unittest_assert_method(node: cst.Call, name: str) -> bool: | |
return ( |
This file contains hidden or 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
@pytest.hookimpl(hookwrapper=True) | |
def pytest_report_teststatus(report, config): | |
outcome = yield | |
res = outcome.get_result() | |
attr_name = "___TIME___" | |
if report.when == "setup": | |
# HACK: store the start time in `config` | |
setattr(config, attr_name, time.time()) | |
elif report.when == "call": |