Skip to main content

package to ingest data in Google Sheets file for FInOps reporting

Project description

FORE stand for Fin Ops REporter

Autentication and authorization Overview

This package will be published on PyPi as downloadable package. The main purpose of it is to Oauth2 authenticate a user of the Jupiter Notebook (JpN) that will need access to Google Sheets application. The security context is the current macOS user who use the Jupiter notebook and is logged in with Google's account. In order to ustilize the Google's Sheets API the JpN code would need to:

  • enable Google Sheet API in the GCP project where the application is registered.
  • install the package fore from PyPi;
  • recieve a file credentials.json from her line manager and copy it to ~/crgoauth folder. This file contains the JpN application's credentials. The security context for the credentials is https://www.googleapis.com/auth/spreadsheets;
  • Logging in the Cloudreach's google account and in the prompted window authorized the JpN application to access the Google Sheets API.

As of the initial version, the authentication of the user is performed over the Google's SignIn of the currently logged user in the Google account in the browser. The authentication token is stored in a subfolder crgoauth in the current user's folder on the local machine (macOS tested). For every authentication attempt the token will be taken from the file from that location only.

In order to work with Google's Sheets API, a credentials file is required as well as outcome of registering this library as desktop application in Google Cloud. The credentials file is always sought in the subfolder crgoauth of the current user's folder on the local machine.

TODO [dev]: to implemnt posibility to store the token and application credentials into Secret MAnager.

HowTos

  • Import customer's report data from pandas' DataFrame:
    • using the fore_cloudreach library in Jupyter notebook:

example-1:

    !pip install fore_cloudreach

    import fore_cloudreach as fc

    try:
        ing = fc.Ingester("<customers_map>")
        rsl = ing.load_from_df("customer", <data_frame>)
        
        print(rsl)

    except Exception as err:
        print("An exception raised: {err}!")

where:

  • <customers_map> is the file ID from the URL of a Google's Sheets file containing the mapping between a customer and its report file ID.

*Example:*
</br>
*The file ID to pickup from the file URL*
![ID from URL](docs/url-img.png)
and then:
```python
    ing = fc.Ingester("1FE0KDANyCLk_zhyxCsIGPR4ifaktD9xMt...")
```
The mapping file format:
![cstumer map sample](docs/cst-map.jpeg)

**IMPORTANT !!!**
The customer mapping tab sheet MUST be named <`Map`>!
  • <customer> is one of customer name or customer id (as string) as it is used in the mapping file described above.

  • <data_frame> - is pandas Data Frame with the data to be uploaded in the customers report sheet.


example-2:

  1. Install the library
    pip install fore_cloudreach

    # on Jupyter notebook:
    ! pip install fore_cloudreach
  1. Import and usage
    
    import fore_cloudreach as fc

    # ... Acquire the customer's reports data into pandas Data Frame or CSV file
    #        
    # ... create an Ingester object by next statement
    # where `mapping_file_id` is the unique file ID from the URL of the Google Sheets file. This must be a configuration file that maps 
    # the customers to their Google Sheets report file per each customer.

    ing = fc.Ingester(mapping_file_id="1fL3rZDj8tCP4povb3E2x_WmkqNmfEZIR...")

    # to load the report from pandas DF run the following code, where you need:
    # the customer name (str) and the data set as pandas Data Frame
    rsl = ing.load_report(customer="<customer_name>", data=df)

    # to load the report from CSV file run the following code, where you need:
    # the customer name (str) and the data = string as relative path to the CSV file     
    rsl2 = ing.load_report(customer="<customer_name>", data="docs/samples/aws_ec2_rightsizing.Csv")

    # the returned result will show a summary of a successful import

Project details


Download files

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

Source Distribution

fore_cloudreach-0.0.1.dev9.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fore_cloudreach-0.0.1.dev9-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file fore_cloudreach-0.0.1.dev9.tar.gz.

File metadata

  • Download URL: fore_cloudreach-0.0.1.dev9.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for fore_cloudreach-0.0.1.dev9.tar.gz
Algorithm Hash digest
SHA256 eb90625a271973048fb5b06037b8f8901a6dabd8bc601d5baeb832203eca5568
MD5 c83ff58155710fb19f8a92ee4558e4c6
BLAKE2b-256 b4fba4720773343cbbc94119952d2e5b63d97644b7030fcf64d4d5ce4c64dc47

See more details on using hashes here.

File details

Details for the file fore_cloudreach-0.0.1.dev9-py3-none-any.whl.

File metadata

File hashes

Hashes for fore_cloudreach-0.0.1.dev9-py3-none-any.whl
Algorithm Hash digest
SHA256 67aeceb9e29603cb697085f462a6705681fd26772f8390bf221aed3b000caba6
MD5 23def5fa0dfbe4130818dcd59b5aa644
BLAKE2b-256 8f23b55e7de5cbe93f23c74283038628c79bccf16ce7241a9ddb31892e815d4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page