Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make ITA taxonomy available as a JSON blob

Notifications You must be signed in to change notification settings

InternationalTradeAdministration/ita-taxonomy-normalizer

Repository files navigation

CircleCI Maintainability Dependabot Status

ITA Taxonomy Normalizer

This project provides an Azure Function that periodically creates a single JSON document from the custom Taxonomy endpoint at https://api.trade.gov. It uploads that JSON file to a Blob in an Azure Container.

Prerequisites

  • This project is tested against Python 3.7+ in CircleCI.

Getting Started

git clone [email protected]:InternationalTradeAdministration/ita-taxonomy-normalizer.git
cd ita-taxonomy-normalizer
mkvirtualenv -p /usr/local/bin/python3.8 -r requirements-test.txt ita-taxonomy-normalizer

Tests

python -m pytest

Environment Variables

Variable Name Description
API_KEY Your api.trade.gov key
AzureWebJobsStorage Azure storage connection string e.g. DefaultEndpointsProtocol=https;AccountName=foo;AccountKey=mykey==;EndpointSuffix=core.windows.net
CONTAINER_NAME Destination container for JSON file
FILE_NAME Destination file name (defaults to ita_taxonomy_labels.json)

Invocation

The easiest way to invoke the function locally is to set the above environment variables and run it manually:

python TimerTrigger/taxonomy_io.py

Alternatively, you can create a local.settings.json file in the root of this project containing the appropriate values:

{
  "IsEncrypted": false,
  "Values": {
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=foo;AccountKey=mykey==;EndpointSuffix=core.windows.net",
    "API_KEY": "your_key",
    "CONTAINER_NAME": "demo"
  }
}

This relies on the cron scheduler in TimerTrigger/function.json to trigger the function:

func start

You specify the schedule in the form of a NCRONTAB expression.

Deploy

Create the FunctionApp in Azure and set up the environment variables in Settings -> Configuration -> Application settings.

Then deploy:

func azure functionapp publish ita-taxonomy-normalizer

About

Make ITA taxonomy available as a JSON blob

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages