X

Week 3: Starting Over?

Mar 28, 2020

Welcome back,

While the name of the blog post is half a dramatic title to lure you into reading my content, it’s half true. All last week, and at the beginning of this week, I was having trouble getting Luigid (Luigi’s central scheduler and GUI) to load. Unlike other problems that I’ve experienced, this one seemed to be unique to me – nobody else on the internet has faced the error that came up every time. After talking through it with my onsite (effectively offsite) advisor, we decided that we would drop Luigi. This was hard to do, considering that I put a lot of hard work into understanding the structures of the library. However, its use seemed to be dragging me down more than it was helping.

Warning: There’s a lot of content here. Sorry. A lot happened. Don’t read if you don’t feel like it!

 

Brainstorm

While I had to go back to the drawing board on how I would organize my tasks, I had a much better understanding of how I wanted my final product to look. I started by coming up with precisely what I want my program to look like, and I ended up with this:

As you can see, each task name lines up on the left, followed by each status (Pending, Running, Complete, Failure) and their links. The links would lead to different directory locations and would swiftly bring the user to all output files created. In the meantime, I decided that it was time to refine my tasks:

Produce1: Run a batch file that creates two files (one .log, one .error). When these are created, the program checks the .error file, and if there is no text within that file, the program is considered complete.

Zip1: Find all of the .log and .error files within the directory of Produce1 and move them all into a .zip file. The program is considered complete if there are no more .log or .error files in the directory.

Produce2: The same thing as Produce1, but through a different directory.

Zip2: The same thing as Zip1, but through the directory of Produce2.

While these are not very complicated programs, they replicate those that Unanet’s customer will be running. I want the two cycles so that I can show movement between different directories and files.

 

User interface/development

I then moved on to finding a proper GUI to show the progression of these tasks. After looking up “best python simple GUI” on google, you wouldn’t be surprised that the library I chose is called “PySimpleGUI.” I spent a lot of hours figuring out this library (just as I did with Luigi). For me, learning is most efficient through examples where I can see the code and its output, and sadly, there were few examples in the manual. Nevertheless, I was able to get a lot done. For some reason, it’s not letting me put in a screenshot of the GUI, but you can click here to see it on another page…

The program starts with just the task names hardcoded into the GUI as text blocks. There are hidden text blocks, though, that are capable of holding text when updated later – these are where the statuses and links go. When the user clicks “Start,” all of the tasks listed above start to progress, and all statuses are updated to “Pending.” As each task runs and finishes, the program updates the status textbox to “Running,” then “Done” or “Failed.” At the same time, the expected directory links appear below the task. This repeats until all tasks are complete.

There are still some things that I am working through in this GUI. My main problem is that the update function mentioned above does not hold priority. In other words, the program will not update the GUI until it has nothing else to do or run, so currently, when I run the program, the statuses go from all “Pending” to all “Done.”

 

Experience

While it was a shame to drop all of my progress with Luigi, I enjoy the learning and creating process. My given task was very open – I could have approached it from several different directions – and I am glad that I got to experience that again. Towards the end of my time with Luigi, the work was getting hopeless – I didn’t feel confident that I could fight my way around the problem. Starting with PySimpleGUI was also more enjoyable than my first time around because the outputs were not just strings of words, but also graphics and visuals.

In the coming weeks, I plan to revisit my XML plan from before (see paragraph #2 of Week 2: Refined Tasks And GUI Troubleshooting for details). I admittedly cringe when saying that, because I expect this to be a challenging add-on to an already complicated program. Come back next week to see how it goes!

 

PS: If you’d like to test/play around with the code I wrote, it is attached here. Run it through Python, and make sure you install PySimpleGUI first (type ‘pip install PySimpleGUI’ into windows command prompt, not sure exactly how to do it on mac). It will be limited in its capabilities because you don’t have the same files and directories, but the introductory GUI should show up. I’d love to hear feedback in the comments!

PPS: For those on the opposite side, I realize that my technical descriptions could seem cryptic to those who are unfamiliar with Python or technology in general. Please leave questions in the comment section if you seek clarity  : )

 

4 Replies to “Week 3: Starting Over?”

  1. Ethan H. says:

    Awesome progress! It’s a shame Luigid wasn’t able to load, especially because of the hard work you’d already spent learning about Luigi, but PySimpleGUI seems just as good, if not better, than Luigi.
    Thanks for including a link to your code in your blog post. It’s awesome to see that you’ve been using many of the same concepts that I’ve been using for my project (reading and writing to text files, changing directories using the os library in Python, etc). I will definitely download your code and use it as a template for any GUIs in the future!
    Again, great progress! Looking forward to reading next week’s post!

    1. Thomas E. says:

      Thanks for the feedback, Ethan. I’m glad someone found interest in my work!

      They say ‘knowledge is power,’ so the fact that I got some practice with Python and its structures is a plus. I guess utility is power too, and thankfully I was able to reuse a lot of the work I had already done on designing my tasks.

      1. Mr. Loomis says:

        “And with great power, comes great responsibility’, at least that’s what Peter Parker’s uncle said. 🙂

Leave a Reply