Skip to main content

A few ready-to use python tools for machine learning

Project description


A few ready-to use python tools for machine learning


pip install flashtool

Logger (to file)

For every print function, we print a copy to file without changing the whole file.

Logger(filepath = "./log.txt", mode = "w", stdout = None)
  • filepath: output path. Default: "./log.txt"
  • mode: write mode, e.g., w,w+,a,a+. Default: "w"
  • stdout: capture which print source. Default: "sys.stdout"


from flashtool import Logger
import sys
sys.stdout = Logger("path/to/log/file/log.txt")
sys.stdout = Logger("path/to/log/file/log.txt","w")
sys.stdout = Logger("path/to/log/file/log.txt","w", sys.stdout)

Email Module

Default Sender: You need a password for this.

# Function api
def send_email(port = 587,password = None,
        sender_email = "",
        receiver_email = None,
        message="Hello! ",

# Example
from flashtool import send_email
send_email(receiver_email="", subject="Hi", message="first email")

Track Job

Track your job. Send you an email when it is done.

Tracking by PID

  • Step 1: find your job pid by ps, e.g., ps aux | grep python
  • Step 2:
from flashtool import trackpid


def trackpid(pid, checktime=1, receiver_email=None, sender_email="", msg=""):
  • pid: pid or pids
  • checktime: check pid every checktime seconds
  • msg: additional message

Pytorch Utils

GPU Usage

import flashtool as flash; flash.check_torch_memory(brief=True)
  • brief: short message (default: Flase)

Auto Script Running

import flashtool as flash;
    "DATA": "subset5"
flash.run_script(basescript, config)

Profile Timing Line by Line

from flashtool import line_time_profiler 

def f(n=1000):
    a = [1 for _ in range(n)]
    b = sum(a)


class C:
    def f(self, n=1000):
        a = [1 for _ in range(n)]
        b = sum(a)

ins = C()

def f(n=1000):
    a = [1 for _ in range(n)]
    b = sum(a)


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flashtool, version 0.0.10
Filename, size File type Python version Upload date Hashes
Filename, size flashtool-0.0.10.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View
Filename, size flashtool-0.0.10-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page