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

added hf token #1043

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions .github/workflows/test-language-lang_id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ jobs:
echo "publish_images=$publish_images" >> "$GITHUB_OUTPUT"
test-src:
runs-on: ubuntu-22.04
env:
HF_READ_ACCESS_TOKEN: ${{ secrets.HF_READ_ACCESS_TOKEN }}
DOCKER_REGISTRY_USER: ${{ secrets.DOCKER_REGISTRY_USER }}
DOCKER_REGISTRY_KEY: ${{ secrets.DOCKER_REGISTRY_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 3 additions & 1 deletion transforms/language/lang_id/test/test_lang_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# limitations under the License.
################################################################################

import os
import pyarrow as pa
from data_processing.test_support.transform.table_transform_test import (
AbstractTableTransformTest,
Expand All @@ -26,13 +27,14 @@ class TestLangIdentificationTransform(AbstractTableTransformTest):

def get_test_transform_fixtures(self) -> list[tuple]:
config = {
"model_credential": "PUT YOUR OWN HUGGINGFACE CREDENTIAL",
"model_credential": os.environ.get('HF_READ_ACCESS_TOKEN', "PUT YOUR OWN HUGGINGFACE CREDENTIAL"),
"model_kind": KIND_FASTTEXT,
"model_url": "facebook/fasttext-language-identification",
"content_column_name": "contents",
"output_lang_column_name": "l",
"output_score_column_name": "s",
}
print(os.environ)
table = pa.Table.from_arrays(
[
pa.array(
Expand Down
2 changes: 1 addition & 1 deletion transforms/language/lang_id/test/test_lang_id_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestPythonLangIdentificationTransform(AbstractTransformLauncherTest):

def get_test_transform_fixtures(self) -> list[tuple]:
cli_params = {
"lang_id_model_credential": "PUT YOUR OWN HUGGINGFACE CREDENTIAL",
"lang_id_model_credential": os.environ.get('HF_READ_ACCESS_TOKEN', "PUT YOUR OWN HUGGINGFACE CREDENTIAL"),
"lang_id_model_kind": KIND_FASTTEXT,
"lang_id_model_url": "facebook/fasttext-language-identification",
"lang_id_content_column_name": "text",
Expand Down
2 changes: 1 addition & 1 deletion transforms/language/lang_id/test/test_lang_id_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_test_transform_fixtures(self) -> list[tuple]:
basedir = "../test-data"
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), basedir))
config = {
model_credential_cli_param: "PUT YOUR OWN HUGGINGFACE CREDENTIAL",
model_credential_cli_param: os.environ.get('HF_READ_ACCESS_TOKEN', "PUT YOUR OWN HUGGINGFACE CREDENTIAL"),
model_kind_cli_param: KIND_FASTTEXT,
model_url_cli_param: "facebook/fasttext-language-identification",
content_column_name_cli_param: "text",
Expand Down
6 changes: 5 additions & 1 deletion transforms/language/lang_id/test/test_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
# limitations under the License.
################################################################################

import os
import pyarrow as pa
from dpk_lang_id.lang_models import KIND_FASTTEXT, LangModelFactory
from dpk_lang_id.nlp import get_lang_ds_pa


def test_language_identification():
nlp_langid = LangModelFactory.create_model(
KIND_FASTTEXT, "facebook/fasttext-language-identification", "YOUR HUGGING FACE ACCOUNT TOKEN"
KIND_FASTTEXT,
"facebook/fasttext-language-identification",
os.environ.get('HF_READ_ACCESS_TOKEN', "YOUR HUGGING FACE ACCOUNT TOKEN")
)

documents = pa.array(
[
"Der Tell Sabi Abyad („Hügel des weißen Jungen“) ist eine historische "
Expand Down
Loading