I need help writing pytorch-lightning progress to a new shell or cmd window. Whenever trainer.fit is called, I want a new window to come up and the training progress and metrics should be displayed there.
I know the default write path of pytorch-lightnig tqdm writter is "stdout". I wand the "stdout" to be that of a new shell not the current main one.
Related
I am new with GUI programming in Python 3.x with Tkinter.
I have prepared a GUI where user needs to select options (using OptionMenu widget) and after selection press button to run the final program.
I have saved the user selected data into variables in that GUI program.
But don't know what should I do next...
What I want:
That GUI should be hidden or End after pressing the button.
Run another python script and use those saved variables from that GUI in my script.
How it can be done in python.
You can save your data in another file in order to use it in other script with pickle module.
To save you can do a list with all the variables you want:
import pickle
with open('doc_name.txt','wb') as a:
pickle.dump(saved_variable_list,a)
And in another python script you can use that list of variables:
import pickle
with open('doc_name.txt','rb') as a:
saved_variable_list = pickle.load(a)
Finally to close your GUI you can use the 'destroy' command:
root.destroy()
I try to create a small GUI with tkinter. To make my code more readable I want to split the code in 2 files. One for the GUI information and one for the process informations. Or is it a bad idea?
So I create a gui.py where I import my process informations from program.py.
gui.py:
import tkinter as tk
from program import *
root = tk.Tk()
btn_Start = tk.Button(text="Start", command=start_loop)
btn_Stop = tk.Button(text="Stop", command=stop_loop, state=tk.DISABLED)
btn_Start.grid(row=1, column=0)
btn_Stop.grid(row=1, column=1)
root.mainloop()
program.py:
def start_loop():
print('disable Start button and enable Stop button')
# what is the code to disable the start button and enable the stop button?
def stop_loop():
print('disable Stop button and enable Start button')
# what is the code to disable the stop button and enable the start button?
How do I tell the button the disable/enable information in my program.py file? I do not understand how I get the information from the gui to the program and back to the gui?
Thanks for your help
For such a small program, it is overkill.
Looking at the tkinter programs I've written, all of them are between 200−300 lines. This is including headers, comments and blank lines. The number of actual code lines is 100−200.
In my opinion that is small enough to comfortably handle in an editor in one file.
Looking over most of my source code repositories, the longest Python files tend to top out at around 230 lines of actual code.
Keeping all the code in one file has significant advantages for a program when you need to install it. Just copy the file and you're done. No need for modules and a setup.py.
I am running a series of operations inside a Jupyter notebook. Some of those operations, print their results on the console pane which when executed inside a notebook environment, the results show up in the Jupyter notebook's console window. I need to save those logs as well.
Is there a way that I can save that console's content ?
Or even better, Is there a way that I can altogether make any messages that are sent to console, being saved/piped/redirected to a file instead ?
Please note that, I myself do print some messages inside notebook, and I don't want to save those messages to the file. I specifically want a third application/library which prints its messages on a console, get saved/redirected to a file.
Therefore simply doing :
sys.stdout = open('file', 'w')
is not a viable choice, because it saves the print messages inside the notebook and not the ones displayed on the console.
I have some python functions to create graphical interface components in jupyter (lab) using ipywidgets. For my specific application, it's very useful to create different views for different cell outputs containing different widgets. I do this manually with "right click / create new view for output". However, sometimes this process gets annoying when I close everything and come back to work on it later, because I have to redo this layout manually every time and I was wondering if there's a way to write a single script (that I can run from some command line interface) that basically sets this up automatically, i.e. run commands in a jupyter lab session, get specific output cells and send them to different views, etc. Is there a way to do this?
I am using jupyter notebook to practice this problem on kaggle https://www.kaggle.com/c/word2vec-nlp-tutorial/details/part-1-for-beginners-bag-of-words.
When I use the following code
import nltk
nltk.download() # Download text data sets, including stop words
Kernel goes in the busy state and then I am unable to execute any cells further.
When you run nltk.download(), it launches an interactive GUI window that you can use to download resources. But very often this window is hidden behind other windows on your screen. Look for it, download anything you need and then close the downloader window in order for your script to return control to the notebook kernel.
To avoid hanging when your code gets to a download command, you could use a non-interactive download command instead. E.g., nltk.download("brown") for the Brown corpus, or nltk.download("book") to get all resources needed when reading through the nltk book. These carry out the download (even if you already have the requested resource) without opening a GUI window. For this you'll need to know, or guess, the internal name of the resource you want.