In your Python scripts, then, import the package by using
from dotenv import load_dotenvimport os
and load the environmental variables by running load_dotenv() before using the variables in your script.
You will then be able to access your environmental variables by using os.getenv("VAR_NAME"), like so:
API_KEY = os.getenv("API_KEY")
Create a new project with the category schema and workflow of an existing one
from imerit_ango.sdk import SDK # Minimum version 1.3.12from dotenv import load_dotenvimport osload_dotenv()# Import the API Key and Project ID from the .env fileapiKey = os.getenv('api_key')projectId = os.getenv('project_id')# Create an instance of the SDK, using the API Keyango_sdk =SDK(apiKey)# Get Existing Project Responseexisting_project_response =\ ango_sdk\.get_project( project_id=projectId )# Copy the Workflow from the Existing Projectcopied_workflow =\ existing_project_response\.get("data")\.get("project")\.get("stages")# Copy the Category Schema from the Existing Projectcopied_categories =\ existing_project_response\.get("data")\.get("project")\.get("categorySchema")# Create new project and get the project id new_project_id =\ ango_sdk\.create_project("New Project", "with copied category schema and workflows" )\.get("data")\.get("project")\.get("_id")print("New Project ID: ", new_project_id)# Import copied category schema to the new project idcopied_cat_resp =\ ango_sdk\.create_label_set( project_id=new_project_id, raw_category_schema = copied_categories )print("Copied Category Schema Response: ", copied_cat_resp.get("status"))# Import copied workflow to the new project idcopied_workflow_resp =\ ango_sdk\.update_workflow_stages( project_id=new_project_id, stages=copied_workflow )print("Copied Workflow Response: ", copied_workflow_resp.get("status"))