Skip to content

Project setup and productivity

jgregoriBb edited this page Dec 15, 2022 · 5 revisions

Starter template

A starter template is provided to make starting projects with the Bb_rest_helper library as easy and painless as possible. The template is here and provides the basic functionality to:

  1. Import the required classes.
  2. Set logging.
  3. Get configuration info from configuration file. (refer to documentation on config files)
  4. Authenticate and return the token and URL (for convenience)
#imports.
from Bb_rest_helper import Bb_Utils
from Bb_rest_helper import Get_Config
from Bb_rest_helper import Auth_Helper
from Bb_rest_helper import Bb_Requests

#logging and utils initialization.
utils = Bb_Utils()
utils.set_logging()

#Authenticate and get the token (Learn).
quick_auth_learn = utils.quick_auth('./credentials/config.json')

#Retrieve token and server url
learn_token = quick_auth_learn['token']
learn_url = quick_auth_learn['url']

print(learn_token,learn_url)

#Initialize Rest API calls
reqs = Bb_Requests()

#Your code goes here

Starter notebook for Jupyter

Additionally, the exact same code as above is provided in a Jupyter notebook. These are great for research and testing as it is easy to break down the functionality in code cells that can run independently

To use the notebook, in addition to the configuration explained in the documentation, it is necessary to install Jypyter. Also, I would recommend to check out the Jupyter extension for VS studio code.

#make sure that your virtual environment is active
Pip3 install Jupyter

Repository template

For more advanced users, the repository template here allows to quickly create a Github repository with a project blueprint (including base documentation). This template repository includes.

  1. Credentials folder with credentials template, you only need to fill in the information from your server, key and secret
  2. LICENSE.md, feel free to change to the license you want to use.
  3. README.md, with base documentation to be used as a starter
  4. app.py as the main application file that imports helper classed and where the main functionality will be coded
  5. gitignore to avoid configuration, env and other files to be uploaded to a public/private repository. Make sure to change the name to **".gitignore" in your local folder so it becomes active
  6. requirements.txt to install dependencies
  7. research.ipnyb Jupyter notebook with starter code for testing and research
  8. script_helper to add all helper clases for the project that can be imported and called from app.py. by default contains a Helper class that already initialises the Bb_rest_helper
Clone this wiki locally