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....

gamer's interview

This project simulates a gamer's interview. Based on NodeJS+ ReactJS The setting is interviewing a gamer/journalist what's his/her plan of March 2020? The gamer answers his/her game list in plan, how many reviews on demand and how many hours expected. Games selected for review take 5 hours for each, while others take one. This project is designed to practice render html, jsx, component, props introduced in  https://www.w3schools.com/REACT/default.asp . Also fixed other issues to make it work. When trying to modualize objects and tools, my design developed to separate views and processes. And it is quite similar to the initialized structure NodeJS+ReactJS provided. Furthermore, since include local module files are banned by browsers, use NodeJS service seems to be the best option. view file main process object tool

Comments for my Server/Client Web API samples

        Finally, I finished the comments for python/07 and 09 projects. I almost forgot to put the date on source code which is used to note how long it took me. Not precisely in hours….. I didn’t include source code in my previous post. If choosing code-section for this post…… maybe I want to mark out my comment….. (Really?!)          Once my work was developing websites for enterprises, including ERP, CRM or content sites. The sustainability of network and security are important issues. There are 2 methods for HTML Form submission: GET and POST. Submit via POST is secure, compared to GET which piles parameters on URL. RESTful API is mainly using GET.         Yup, even if you have a certification key, if you put the value on the URL, it is visible data. When writing socket-communication, client-server sockets are a pair; both follow the agreement on commands and structures; and there are countless ports for usa...