Skip to main content

Sample for client RESTful API, pandas, tqdm, argparse

    Here is a good example for practicing:


    Why I didn't mention it as "good tutorial" because I encounter several obstacles while working on this example (then it became a project..) Probably 
  • related tools' reversion is the main issue. IT is a fast changing world. Many tutorials I found online are already invalid. 
  • the author was using both programming and terminal. I was mainly on programming because data processing/conversion in advance;
  • Skipping complex  work, ex. temporary storage. 
    At beginning I expected to complete this exercise in one file. But at the end, to deal with multiple obstacles, It grew to mobilized functions (options/database/REST loading/parsing) , many steps ( at least 7, not including removed tests) and many tests..... 

    In order to deal with multiple REST querying and its agreement of usage, 
I employed SQLite3. At first, I was using saving-files to keep records instead of harassing server while debugging. I thought of saving multiple files during multiple REST queries and save all into one file at the end. I assume saving file is convenient to verify content, since I don't have GUI viewers for SQLite file format. But, considering the possibility that other programmers/learners may want to test on my project and querying REST thousands of times, creating thousands of files and deleting them in a sudden seems suspicious... I can't guarantee REST query will always succeed, nor my program was robust,  so saving-data is on progress, instead of at the end. Therefor I developed tier 2 for database storage. And later on, some options only provide database storage. 

    But as expected, it is inconvenient to view the raw data to decipher its scheme. Many database related testing functions are only for viewing purpose. And then adding action_id to distinguish what is this data for, some are from REST query, some are rebuilt JSON after processing. 


    Here are some modules the author mentioned or I found during developing. 

Module: argparse


parser = argparse.ArgumentParser()
parser.add_argument(...)    
args = parser.parse_args()


Docs in python is detailed, and this module can also take function to check valid values. but how many keyword it adapt.....? A ha~ I found one occurrence of string type on this page... And required tag for the value of omittable argument is so far away.... 

Here is a simple version if you don't want to be a argparse expert yet. 


   This module make expanding arguments much easier. 

Module: pandas 


    This is the module took me most of time while developing, because, on tutorial or most online examples, developers are using them on terminal. Its functionality on terminal is very muck alike programming. After all other bugs fixed and still nothing showing out, I finally discovered that something showing on terminal, didn't return by code..... And something absolutely different on output wasn't changed on object... And even when the view are the same, they are under different axis-definition at import.... And this make one column merge failed..... 

    This is my 2nd time visited module pandas. At first time, I don't know what to do for practicing. This tutorial proposed good samples. 
    Yes, pandas is powerful

Module: tqdm


    This is a simple and amusing progressing bar. I see it often when updating developing environment. It also forced me to understand pandas.DataFrame.apply(). What would be pushed in as parameters and how I can add extras,  
(But it seem that pandas is going to remove panel sharing.... Which tqdm depends on.  Let's see how would it go.)



Comments

  1. Here we record all the games that have the thrill of thecasinosource.com on line casino games and the potential to win but do not fall into a specific category, corresponding to scratch playing cards and arcade games. If may be} on the lookout for an informal experience, this must be one of the first sections you should to} visit. Choose your on line casino wisely so that you can|so as to|to have the ability to} enjoy the experience extra.

    ReplyDelete

Post a Comment

Popular posts from this blog

Bookmark service (MongoDB & Spring REST) -2/2

    I accidentally deleted my development VM. I got lucky having the habit of taking notes. This blog is useful. Development VM is doom to be lost. Rebuild it waste time, but having a clean slate is refreshing~. What concerns me more is my AWS free quota this month is reaching 85%. The second VM I launched but never being used might be the one to blame. (Of course, my mistake.) I terminated the wrong VM. Now I got Linux 2 built. Great, just threw away everything happened on AMI.  1st layer: Page Page class   Originally, I need to prepare getter/setter for all class properties for Spring. By using lombok, I only need to create constructors. lombok will deal with getter/setter and toString(). But there are chances to call getter/setter, but how? .......Naming convention.... Capitalize the 1st character with the prefix get/set.  Annotation @Data was used on this class.  Repository class Spring Docs: Repository https://docs.spring.io/spring-data/mongodb/docs/3....

Guide to Preserving HuggingFace Models in Google Colab Environments

Conclusion:  Step 1:  find the model path: ls ~/.cache  Step 2:  Copy the entire folder to Google Drive:  Step 3:  Set model path to the subfolder under snapshot: My Story: I initially began exploring Generative AI (GAI) and Google Colab through Stable Diffusion. In the past, as I mainly wrote server services and console applications, I was less familiar with data science modes like R and Jupyter that can maintain a paused state. I didn't quite understand the heavy burden on Colab of creating a temporary Stable Diffusion WebUI with .ipynb, as suggested by popular guides. I just found it troublesome that connections often took a long time and then dropped, requiring a restart. Recently, while testing new versions of the Stable Diffusion model, and facing challenges due to Colab's policies making various versions of WebUI difficult to run successfully, I started researching how to write my own test programs in Colab. Eventually, I understood that Colab is ess...

Setup Maven and two basic projects

    The interesting implementation of Java I proceed to is Spring. And, only getting Java running is not enough. I also need to set up Maven. This name is new to me, and I found many Spring tutorials just skip this part. At least I need Maven to generate templates for me. I should learn it more. ( I knew there is a great tool -- Eclipse -- can make tedious things disappear. I’m taking a strategy to install all experiments I want to try and throw away when it's full. And that's an external VM, not my PC. I, not yet, want to do research about installing Eclipse on AMI. )    Upgrade to Java 8     First is to upgrade Java on AMI to Java8. AWS provides advanced tools for Linux 2. And DIY for Linux2. At least there are solutions for my choice.  Amazon Corretto 8 Installation Instructions for Amazon Linux 2 https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/amazon-linux-install.html Here are commands I used: >wget */amazon-corretto-8-x64-linux-jdk.d...