Skip to content

Commit

Permalink
Merge pull request #210 from NationalLibraryOfNorway/feat/dotenv-conf
Browse files Browse the repository at this point in the history
feat: use python-dotenv for config
  • Loading branch information
magbb authored Aug 1, 2024
2 parents 2feb62d + b8f1d78 commit 9e0ac12
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions dhlab.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NB_DHLAB_BASE_URL = "https://api.nb.no/dhlab" #: REST-API URL adress to fulltext query functions
NB_DHLAB_NGRAM_API = "https://api.nb.no/dhlab/nb_ngram/ngram/query" #: URL adress for API calls to ngram-databases
NB_DHLAB_GALAXY_API = "https://api.nb.no/dhlab/nb_ngram_galaxies/galaxies/query" #: URL adress for word galaxy API queries
13 changes: 9 additions & 4 deletions dhlab/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"""Constant variables used across modules."""
import os
from dotenv import load_dotenv

BASE_URL = "https://api.nb.no/dhlab" #: REST-API URL adress to fulltext query functions
NGRAM_API = "https://api.nb.no/dhlab/nb_ngram/ngram/query" #: URL adress for API calls to ngram-databases
GALAXY_API = "https://api.nb.no/dhlab/nb_ngram_galaxies/galaxies/query" #: URL adress for word galaxy API queries
load_dotenv("dhlab.env") # take environment variables

"""Constant variables used across modules, change in dhlab.env or through environment variable"""

BASE_URL = os.getenv("NB_DHLAB_BASE_URL") #: REST-API URL adress to fulltext query functions
NGRAM_API = os.getenv("NB_DHLAB_NGRAM_API") #: URL adress for API calls to ngram-databases
GALAXY_API = os.getenv("NB_DHLAB_GALAXY_API") #: URL adress for word galaxy API queries
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ scipy = { version = "^1.11.3", python = ">=3.9,<3.13" }
openpyxl = "^3.1.2"
beautifulsoup4 = "^4.12.2"
numpy = "^1.26.3"
python-dotenv = "^1.0.1"

[tool.poetry.group.docs.dependencies]
Sphinx = "^7.2.6"
Expand Down
3 changes: 2 additions & 1 deletion tests/test_natbib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pytest
from dhlab.metadata.natbib import metadata_query, metadata_from_urn
import pandas as pd


@pytest.mark.skip()
def test_metadata_query():
conditions = [
["245", "a", "kongen"],
Expand Down

0 comments on commit 9e0ac12

Please sign in to comment.