Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to package #13

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading