Skip to content

Commit

Permalink
Merge pull request #13 from nestauk/tweaks-package
Browse files Browse the repository at this point in the history
Tweaks to package
  • Loading branch information
lizgzil authored Oct 31, 2024
2 parents bd3b677 + 25a56f5 commit f4cedb2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
19 changes: 19 additions & 0 deletions nlp_link/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import yaml
from pathlib import Path
from typing import Optional
import logging


def get_yaml_config(file_path: Path) -> Optional[dict]:
"""Fetch yaml config and return as dict if it exists."""
if file_path.exists():
with open(file_path, "rt") as f:
return yaml.load(f.read(), Loader=yaml.FullLoader)


# Define project base directory
PROJECT_DIR = Path(__file__).resolve().parents[1]

logger = logging.getLogger(__name__)

soc_mapper_config = get_yaml_config(PROJECT_DIR / "nlp_link/soc_mapper/config.yaml")
5 changes: 3 additions & 2 deletions nlp_link/soc_mapper/soc_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from tqdm import tqdm
import numpy as np

from nlp_link import soc_mapper_config

from nlp_link.soc_mapper.soc_map_utils import (
load_job_title_soc,
process_job_title_soc,
Expand All @@ -31,8 +33,7 @@

from nlp_link.linker_utils import load_bert

from utils.utils import (
soc_mapper_config,
from nlp_link.utils.utils import (
load_s3_json,
load_local_json,
save_to_s3,
Expand Down
2 changes: 1 addition & 1 deletion nlp_link/soc_mapper/soc_map_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import re

from utils.utils import soc_mapper_config
from nlp_link import soc_mapper_config


def load_job_title_soc(soc_mapper_config: dict = soc_mapper_config) -> pd.DataFrame():
Expand Down
19 changes: 1 addition & 18 deletions utils/utils.py → nlp_link/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
import yaml
from pathlib import Path
from typing import Optional
import logging
import boto3
import json
from fnmatch import fnmatch
from decimal import Decimal
import numpy


def get_yaml_config(file_path: Path) -> Optional[dict]:
"""Fetch yaml config and return as dict if it exists."""
if file_path.exists():
with open(file_path, "rt") as f:
return yaml.load(f.read(), Loader=yaml.FullLoader)


# Define project base directory
PROJECT_DIR = Path(__file__).resolve().parents[1]

logger = logging.getLogger(__name__)

soc_mapper_config = get_yaml_config(PROJECT_DIR / "nlp_link/soc_mapper/config.yaml")
from nlp_link import logger


def get_s3_resource():
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nlp-link"
version = "0.1.2"
version = "0.1.3"
description = "A python package to semantically link two lists of texts."
authors = ["Nesta <[email protected]>"]
readme = "README.md"
Expand All @@ -15,10 +15,11 @@ torch = "^1.13.1"
pytest = "^8.3.2"
tqdm = "^4.66.4"
numpy = "^1.26.4"
s3fs = "^2022.5.0"
openpyxl = "^3.1.3"
boto3 = "^1.21.21"
wasabi = "^1.1.3"
s3fs = {extras = ["boto3"], version = ">=2023.12.0"}
boto3 = "*"
botocore = "*"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit f4cedb2

Please sign in to comment.