Initialization and Credentials

[6]:
# Install the datatrails-python package
!{sys.executable} -m pip install --upgrade datatrails-archivist
!(sys.executable) -m pip install --upgrade python-dotenv
Requirement already satisfied: datatrails-archivist in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (0.33.2.post1+git.8e1ac7c7.dirty)
Requirement already satisfied: requests-toolbelt~=1.0 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (1.0.0)
Requirement already satisfied: certifi in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (2024.8.30)
Requirement already satisfied: Jinja2~=3.1 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (3.1.4)
Requirement already satisfied: pyaml-env~=1.2 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (1.2.1)
Requirement already satisfied: backoff~=2.2.1 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (2.2.1)
Requirement already satisfied: flatten-dict~=0.4 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (0.4.2)
Requirement already satisfied: rfc3339~=6.2 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (6.2)
Requirement already satisfied: requests~=2.32 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (2.32.3)
Requirement already satisfied: iso8601~=2.1 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (2.1.0)
Requirement already satisfied: xmltodict~=0.14 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from datatrails-archivist) (0.14.2)
Requirement already satisfied: six<2.0,>=1.12 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from flatten-dict~=0.4->datatrails-archivist) (1.16.0)
Requirement already satisfied: MarkupSafe>=2.0 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from Jinja2~=3.1->datatrails-archivist) (3.0.2)
Requirement already satisfied: PyYAML<=7.0,>=5.0 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from pyaml-env~=1.2->datatrails-archivist) (6.0.2)
Requirement already satisfied: idna<4,>=2.5 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from requests~=2.32->datatrails-archivist) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from requests~=2.32->datatrails-archivist) (2.2.3)
Requirement already satisfied: charset-normalizer<4,>=2 in /home/paul/git/datatrails-python/datatrails-venv/lib/python3.10/site-packages (from requests~=2.32->datatrails-archivist) (3.4.0)
/bin/bash: -c: line 1: syntax error near unexpected token `-m'
/bin/bash: -c: line 1: `(sys.executable) -m pip install --upgrade python-dotenv'
[7]:
from os import environ
from random import randint

unique_id = randint(1, 1_000_000_000)

datatrails_url = environ.get("DATATRAILS_URL", "https//app.datatrails.ai")
datatrails_appreg_client = environ["DATATRAILS_APPREG_CLIENT"]
datatrails_appreg_secret = environ["DATATRAILS_APPREG_SECRET"]
datatrails_artist_attachment = environ["DATATRAILS_ARTIST_ATTACHMENT"]

with open("notebooks.env", "w", encoding="utf-8") as fd:
    fd.write(f'DATATRAILS_URL="{datatrails_url}"\n')
    fd.write(f'DATATRAILS_APPREG_CLIENT="{datatrails_appreg_client}"\n')
    fd.write(f'DATATRAILS_APPREG_SECRET="{datatrails_appreg_secret}"\n')
    fd.write(f'DATATRAILS_ARTIST_ATTACHMENT="{datatrails_artist_attachment}"\n')
    fd.write(f'DATATRAILS_UNIQUE_ID="{unique_id}"\n')

with open("notebooks.env", "r") as fd:
    print(fd.read())
DATATRAILS_URL="https://app.dev-paul-0.dev.datatrails.ai"
DATATRAILS_APPREG_CLIENT="c0232b72-aa68-4596-a9a4-b3f5d3e55255"
DATATRAILS_APPREG_SECRET="5854b9f1b0559db5daf6f57a53e80ac31ac4b14f88dfa679be59d1569acade20"
DATATRAILS_ARTIST_ATTACHMENT="test_files/pexels-andrea-turner-707697.jpeg"
DATATRAILS_UNIQUE_ID="558232363"

[ ]: