def snoopconfig(self, *args, **kwargs): """ config snoop by the `snoop,install` method. see for arguments https://github.com/alexmojaki/snoop/#output-configuration Args: *args: see snoop.install **kwargs: see snoop.install Returns: ClsDebugger:the ClsDebugger object (dd) """ snoop.install(builtins=False, *args, **kwargs) return self
def print_everywhere(): """ https://github.com/alexmojaki/snoop """ txt = """ import snoop; snoop.install() ### can be used anywhere @snoop def myfun(): from snoop import pp pp(myvariable) """ import snoop snoop.install() ### can be used anywhere" print("Decaorator @snoop ")
def main(): foo(1) snoop.install(enabled=False) foo(2) snoop.install(enabled=True) foo(3)
from pathlib import Path from my_types import paramsTup from plot import (multi_bode_axes, multi_bode_add_data, multi_bode_plot_save, get_json_settings, multi_nyquist_add_data, multi_nyquist_axes, multi_nyquist_plot_save) from mung import open_file_numpy, get_params, get_data_numpy, write_imp_data, write_zview_data import snoop import pprint import numpy as np from collections import OrderedDict from typing import List, Tuple, Sequence from dataclasses import dataclass DEBUG = False snoop.install(enabled=DEBUG) @snoop(depth=1) def main() -> None: data_dir = str(Path.cwd()) settings = get_json_settings('settings') both_plot_exists = False phase_plot_exists = False gain_plot_exists = False nyquist_exists = False voltages = [] for filepath in Path(data_dir).glob('*.csv'):
import pytest import six from cheap_repr import cheap_repr, register_repr from cheap_repr.utils import safe_qualname from littleutils import file_to_string, string_to_file from snoop import formatting, install, spy from snoop.configuration import Config from snoop.pp_module import is_deep_arg from snoop.utils import truncate_string, truncate_list, needs_parentheses, NO_ASTTOKENS current_thread()._ident = current_thread()._Thread__ident = 123456789 formatting._get_filename = lambda _: "/path/to_file.py" install() @register_repr(type(cheap_repr)) def repr_function(func, _helper): return '<function %s at %#x>' % ( safe_qualname(func), id(func)) @register_repr(type(sys)) def repr_module(module, _helper): return "<module '%s'>" % module.__name__ @register_repr(set) def repr_set(x, helper):
class Root(DryEnv): DEBUG = True SEPARATE_WORKER_PROCESS = False MASTER_URL = "http://*****:*****@fy0@7c(&lq%)6tt=c+f-(ihd32@t$)i6gjm' GITHUB_TOKEN = "" class MONITOR(DryEnv): ACTIVE = False THRESHOLD = 90 MIN_PROCESSES = 1 NUM_MEASUREMENTS = 3 SLEEP_TIME = 5 snoop.install(enabled=Root.DEBUG, out=sys.__stderr__, columns=['thread']) sentry_sdk.init(dsn=Root.SENTRY_DSN, integrations=[DjangoIntegration()], send_default_pii=True) populate_globals()
import torch from omegaconf import DictConfig, OmegaConf from transformers import AutoTokenizer from data import PunctuationDataModule, PunctuationInferenceDataset, PunctuationDomainDatasets import os from models import PunctuationDomainModel from nemo.utils.exp_manager import exp_manager from time import time from pytorch_lightning.callbacks import ModelCheckpoint import atexit from copy import deepcopy import snoop snoop.install() ## 1. Set experiment path here exp = 'results/2021-03-27_18-00-46' exp = 'pretrained' @hydra.main(config_path=f"../Punctuation_with_Domain_discriminator/{exp}/", config_name="hparams.yaml") # @hydra.main(config_name="config.yaml") def main(cfg: DictConfig) -> None: pl.seed_everything(cfg.seed) torch.set_printoptions(sci_mode=False) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model = PunctuationDomainModel.load_from_checkpoint(
import numpy as np import snoop import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import torchsnooper from torchsummary import summary torchsnooper.register_snoop() snoop.install(enabled=False) BOARD_SIZE = 11 ACTIONS = list(range(BOARD_SIZE**2)) device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") board_ones = torch.ones((BOARD_SIZE, BOARD_SIZE)).to(device) board_zeros = torch.zeros((BOARD_SIZE, BOARD_SIZE)).to(device) board_infs = torch.tensor([[float('Inf')] * BOARD_SIZE] * BOARD_SIZE).to(device) def action_to_coord(a): return (a // BOARD_SIZE, a % BOARD_SIZE) def coord_to_action(i, j): return i * BOARD_SIZE + j # action index