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

Test WASM Translations in CI #927

Merged
merged 17 commits into from
Nov 14, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inference/**/*.gz filter=lfs diff=lfs merge=lfs -text
21 changes: 13 additions & 8 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,19 @@ tasks:

inference-test-wasm:
desc: Run inference build-wasm JS tests.
deps:
- task: inference-build-wasm
vars:
# When the host system is macOS, the WASM build fails when
# building with multiple threads in the Docker container.
# If the host system is macOS, pass -j 1.
CLI_ARGS: '{{if eq (env "HOST_OS") "Darwin"}}-j 1{{end}}'
cmds:
- >-
cd inference/wasm/tests && npm install && npm run test
./inference/scripts/test-wasm.py {{.CLI_ARGS}}

lint-eslint:
desc: Checks the styling of the JS code with eslint.
cmds:
- cd ./inference/wasm/tests && npm install && npm run lint

lint-eslint-fix:
desc: Fixes the styling of the JS code with eslint.
cmds:
- cd ./inference/wasm/tests && npm install && npm run lint:fix

lint-black:
desc: Checks the styling of the Python code with Black.
Expand Down Expand Up @@ -141,12 +144,14 @@ tasks:
lint-fix:
desc: Fix all automatically fixable errors. This is useful to run before pushing.
cmds:
- task: lint-eslint-fix
- task: lint-black-fix
- task: lint-ruff-fix

lint:
desc: Run all available linting tools.
cmds:
- task: lint-eslint
- task: lint-black
- task: lint-ruff

Expand Down
19 changes: 11 additions & 8 deletions inference/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ compile_commands.json
CTestTestfile.cmake
_deps

# Build paths
build
build-local
build-native
build-wasm

/build
/build-local
/build-native
/build-wasm
models
wasm/test_page/node_modules
wasm/module/worker/bergamot-translator-worker.*
wasm/module/browsermt-bergamot-translator-*.tgz
# WASM
wasm/tests/generated
wasm/tests/models/**/*.bin
wasm/tests/models/**/*.spm
wasm/tests/node_modules
wasm/tests/.vitest-reports

# VSCode
.vscode
2 changes: 1 addition & 1 deletion inference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ if(COMPILE_WASM)
-sEXPORTED_FUNCTIONS=[_int8PrepareAFallback,_int8PrepareBFallback,_int8PrepareBFromTransposedFallback,_int8PrepareBFromQuantizedTransposedFallback,_int8PrepareBiasFallback,_int8MultiplyAndAddBiasFallback,_int8SelectColumnsOfBFallback]
# Necessary for mozintgemm linking. This prepares the `wasmMemory` variable ahead of time as
# opposed to delegating that task to the wasm binary itself. This way we can link MozIntGEMM
# module to the same memory as the main bergamot-translator module.
# module to the same memory as the main bergamot-translator-source module.
nordzilla marked this conversation as resolved.
Show resolved Hide resolved
-sIMPORTED_MEMORY=1
# Dynamic execution is either frowned upon or blocked inside browser extensions
-sDYNAMIC_EXECUTION=0
Expand Down
90 changes: 82 additions & 8 deletions inference/scripts/build-wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
MARIAN_PATH = os.path.join(THIRD_PARTY_PATH, "browsermt-marian-dev")
EMSDK_PATH = os.path.join(THIRD_PARTY_PATH, "emsdk")
EMSDK_ENV_PATH = os.path.join(EMSDK_PATH, "emsdk_env.sh")
WASM_PATH = os.path.join(BUILD_PATH, "bergamot-translator-worker.wasm")
JS_PATH = os.path.join(BUILD_PATH, "bergamot-translator-worker.js")
WASM_ARTIFACT = os.path.join(BUILD_PATH, "bergamot-translator.wasm")
JS_ARTIFACT = os.path.join(BUILD_PATH, "bergamot-translator.js")
PATCHES_PATH = os.path.join(INFERENCE_PATH, "patches")
BUILD_DIRECTORY = os.path.join(INFERENCE_PATH, "build-wasm")
GEMM_SCRIPT = os.path.join(INFERENCE_PATH, "wasm", "patch-artifacts-import-gemm-module.sh")
WASM_PATH = os.path.join(INFERENCE_PATH, "wasm")
GEMM_SCRIPT = os.path.join(WASM_PATH, "patch-artifacts-import-gemm-module.sh")
DETECT_DOCKER_SCRIPT = os.path.join(SCRIPTS_PATH, "detect-docker.sh")

patches = [
Expand Down Expand Up @@ -95,6 +96,56 @@ def revert_git_patch(repo_path, patch_path):
subprocess.check_call(["git", "apply", "-R", "--reject", patch_path], cwd=PROJECT_ROOT_PATH)


def prepare_js_artifact():
"""
Prepares the Bergamot JS artifact for use in Gecko by adding the proper license header
to the file, including helpful memory-growth logging, and wrapping the generated code
in a single function that both takes and returns the Bergamot WASM module.
"""
# Start with the license header and function wrapper
source = (
"\n".join(
[
"/* This Source Code Form is subject to the terms of the Mozilla Public",
" * License, v. 2.0. If a copy of the MPL was not distributed with this",
" * file, You can obtain one at http://mozilla.org/MPL/2.0/. */",
"",
"function loadBergamot(Module) {",
"",
]
)
+ "\n"
)

# Read the original JS file and indent its content
with open(JS_ARTIFACT, "r", encoding="utf8") as file:
for line in file:
source += " " + line

# Close the function wrapper
source += "\n return Module;\n}"

# Use the Module's printing
source = source.replace("console.log(", "Module.print(")

# Add instrumentation to log memory size information
source = source.replace(
"function updateGlobalBufferAndViews(buf) {",
"""
function updateGlobalBufferAndViews(buf) {
const mb = (buf.byteLength / 1_000_000).toFixed();
Module.print(
`Growing wasm buffer to ${mb}MB (${buf.byteLength} bytes).`
);
""",
)

print(f"\n📄 Updating {JS_ARTIFACT} in place")
# Write the modified content back to the original file
with open(JS_ARTIFACT, "w", encoding="utf8") as file:
file.write(source)


def build_bergamot(args: Optional[list[str]]):
if args.clobber and os.path.exists(BUILD_PATH):
shutil.rmtree(BUILD_PATH)
Expand Down Expand Up @@ -127,7 +178,18 @@ def run_shell(command):
print("\n🏃 Running CMake for Bergamot\n")
run_shell(f"emcmake cmake -DCOMPILE_WASM=on -DWORMHOLE=off {flags} {INFERENCE_PATH}")

cores = args.j if args.j else multiprocessing.cpu_count()
if args.j:
# If -j is specified explicitly, use it.
cores = args.j
elif os.getenv("HOST_OS") == "Darwin":
# There is an issue building with multiple cores when the Linux Docker container is
# running on a macOS host system. If the Docker container was created with HOST_OS
# set to Darwin, we should use only 1 core to build.
cores = 1
else:
# Otherwise, build with as many cores as we have.
cores = multiprocessing.cpu_count()

print(f"\n🏃 Building Bergamot with emmake using {cores} cores\n")

try:
Expand All @@ -142,14 +204,14 @@ def run_shell(command):
subprocess.check_call(["bash", GEMM_SCRIPT, BUILD_PATH])

print("\n✅ Build complete\n")
print(" " + JS_PATH)
print(" " + WASM_PATH)
print(" " + JS_ARTIFACT)
print(" " + WASM_ARTIFACT)

# Get the sizes of the build artifacts.
wasm_size = os.path.getsize(WASM_PATH)
wasm_size = os.path.getsize(WASM_ARTIFACT)
gzip_size = int(
subprocess.run(
f"gzip -c {WASM_PATH} | wc -c",
f"gzip -c {WASM_ARTIFACT} | wc -c",
check=True,
shell=True,
capture_output=True,
Expand All @@ -158,6 +220,8 @@ def run_shell(command):
print(f" Uncompressed wasm size: {to_human_readable(wasm_size)}")
print(f" Compressed wasm size: {to_human_readable(gzip_size)}")

prepare_js_artifact()

finally:
print("\n🖌️ Reverting the source code patches\n")
for repo_path, patch_path in patches[::-1]:
Expand All @@ -167,6 +231,16 @@ def run_shell(command):
def main():
args = parser.parse_args()

if (
os.path.exists(BUILD_PATH)
and os.path.isdir(BUILD_PATH)
and os.listdir(BUILD_PATH)
and not args.clobber
):
print(f"\n🏗️ Build directory {BUILD_PATH} already exists and is non-empty.\n")
print(" Pass the --clobber flag to rebuild if desired.")
return

if not os.path.exists(THIRD_PARTY_PATH):
os.mkdir(THIRD_PARTY_PATH)

Expand Down
17 changes: 9 additions & 8 deletions inference/scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ cd "$(dirname $0)/.."
# List of directories to clean
dirs=("build-local" "build-wasm" "emsdk")

# Flag to track if any directories were cleaned
cleaned=false

# Check and remove directories
for dir in "${dirs[@]}"; do
if [ -d "$dir" ]; then
echo "Removing $dir..."
rm -rf "$dir"
cleaned=true
fi
done

# If no directories were cleaned, print a message
if [ "$cleaned" = false ]; then
echo "Nothing to clean"
fi
echo "Removing generated wasm artifacts..."
rm -rf wasm/tests/generated/*.js
rm -rf wasm/tests/generated/*.wasm
rm -rf wasm/tests/generated/*.sha256

echo "Removing extracted model files..."
rm -rf wasm/tests/models/**/*.bin
rm -rf wasm/tests/models/**/*.spm

echo
95 changes: 95 additions & 0 deletions inference/scripts/test-wasm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env python3
import argparse
import hashlib
import os
import shutil
import subprocess
import sys

SCRIPTS_PATH = os.path.realpath(os.path.dirname(__file__))
INFERENCE_PATH = os.path.dirname(SCRIPTS_PATH)
BUILD_PATH = os.path.join(INFERENCE_PATH, "build-wasm")
WASM_PATH = os.path.join(INFERENCE_PATH, "wasm")
WASM_TESTS_PATH = os.path.join(WASM_PATH, "tests")
GENERATED_PATH = os.path.join(WASM_TESTS_PATH, "generated")
MODELS_PATH = os.path.join(WASM_TESTS_PATH, "models")
WASM_ARTIFACT = os.path.join(BUILD_PATH, "bergamot-translator.wasm")
JS_ARTIFACT = os.path.join(BUILD_PATH, "bergamot-translator.js")
JS_ARTIFACT_HASH = os.path.join(GENERATED_PATH, "bergamot-translator.js.sha256")


def calculate_sha256(file_path):
sha256_hash = hashlib.sha256()
with open(file_path, "rb") as f:
for byte_block in iter(lambda: f.read(4096), b""):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()


def main():
parser = argparse.ArgumentParser(
description="Test WASM by building and handling artifacts.",
formatter_class=argparse.RawTextHelpFormatter,
)

parser.add_argument("--clobber", action="store_true", help="Clobber the build artifacts")
parser.add_argument(
"--debug",
action="store_true",
help="Build with debug symbols, useful for profiling",
)
parser.add_argument(
"-j",
type=int,
help="Number of cores to use for building (default: all available cores)",
)
args = parser.parse_args()

build_wasm_script = os.path.join(SCRIPTS_PATH, "build-wasm.py")
build_command = [sys.executable, build_wasm_script]
if args.clobber:
build_command.append("--clobber")
if args.debug:
build_command.append("--debug")
if args.j:
build_command.extend(["-j", str(args.j)])

print("\n🚀 Starting build-wasm.py")
subprocess.run(build_command, check=True)

print("\n📥 Pulling translations model files with git lfs\n")
subprocess.run(["git", "lfs", "pull"], cwd=MODELS_PATH, check=True)
print(f" Pulled all files in {MODELS_PATH}")

print("\n📁 Copying generated build artifacts to the WASM test directory\n")

os.makedirs(GENERATED_PATH, exist_ok=True)
shutil.copy2(WASM_ARTIFACT, GENERATED_PATH)
shutil.copy2(JS_ARTIFACT, GENERATED_PATH)

print(f" Copied the following artifacts to {GENERATED_PATH}:")
print(f" - {JS_ARTIFACT}")
print(f" - {WASM_ARTIFACT}")

print(f"\n🔑 Calculating SHA-256 hash of {JS_ARTIFACT}\n")
hash_value = calculate_sha256(JS_ARTIFACT)
with open(JS_ARTIFACT_HASH, "w") as hash_file:
hash_file.write(f"{hash_value} {os.path.basename(JS_ARTIFACT)}\n")
print(f" Hash of {JS_ARTIFACT} written to")
print(f" {JS_ARTIFACT_HASH}")

print("\n📂 Decompressing model files required for WASM testing\n")
subprocess.run(["gzip", "-dkrf", MODELS_PATH], check=True)
print(f" Decompressed models in {MODELS_PATH}\n")

print("\n🔧 Installing npm dependencies for WASM JS tests\n")
subprocess.run(["npm", "install"], cwd=WASM_TESTS_PATH, check=True)

print("\n📊 Running Translations WASM JS tests\n")
subprocess.run(["npm", "run", "test"], cwd=WASM_TESTS_PATH, check=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: In CI I would rather have all this output actually show up so it's easy to deal with test failures. In jest you can have each test that is run enumerated in the log output. It's not clear from the task output that the tests actually ran, or what tests were run.

https://github.com/mozilla/translations/pull/927/checks?check_run_id=32892931631

[task 2024-11-12T23:03:00.175Z] 📂 Decompressing model files required for WASM testing
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z]    Decompressed models in /builds/worker/checkouts/vcs/inference/wasm/tests/models
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 🔧 Installing npm dependencies for WASM JS tests
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 📊 Running Translations WASM JS tests
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] ✅ test-wasm.py completed successfully.
[task 2024-11-12T23:03:00.175Z] 
[taskcluster 2024-11-12 23:03:00.768Z] === Task Finished ===

Copy link
Contributor Author

@nordzilla nordzilla Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you know, this is odd.

Locally, the output looks like this:

🚀 Starting build-wasm.py

🏗️  Build directory /home/nordzilla/src/translations/inference/build-wasm already exists.

   Pass the --clobber flag to rebuild if desired.

📁 Copying generated build artifacts to the WASM test directory

   Copied the following artifacts to /home/nordzilla/src/translations/inference/wasm/tests/generated:
     - /home/nordzilla/src/translations/inference/build-wasm/bergamot-translator.js
     - /home/nordzilla/src/translations/inference/build-wasm/bergamot-translator.wasm

🔑 Calculating SHA-256 hash of /home/nordzilla/src/translations/inference/build-wasm/bergamot-translator.js

   Hash of /home/nordzilla/src/translations/inference/build-wasm/bergamot-translator.js written to
   /home/nordzilla/src/translations/inference/wasm/tests/generated/bergamot-translator.js.sha256

📂 Decompressing model files required for WASM testing

   Decompressed models in /home/nordzilla/src/translations/inference/wasm/tests/models


🔧 Installing npm dependencies for WASM JS tests

(node:111180) ExperimentalWarning: CommonJS module /home/nordzilla/.nvm/versions/node/v23.1.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /home/nordzilla/.nvm/versions/node/v23.1.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

up to date, audited 135 packages in 1s

38 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

📊 Running Translations WASM JS tests


> [email protected] test
> vitest --run


 RUN  v2.1.4 /home/nordzilla/src/translations/inference/wasm/tests

 ✓ test-cases/translate-html-no-pivot.test.mjs (4) 1578ms
   ✓ HTML Non-Pivot Translations (4) 1578ms
     ✓ (es -> en): Translate "<b>El perro</b> azul." 374ms
     ✓ (en -> es): Translate "<b>The blue</b> dog." 423ms
     ✓ (fr -> en): Translate "<b>Le chien</b> bleu." 406ms
     ✓ (en -> fr): Translate "<b>The blue</b> dog." 374ms
 ✓ test-cases/translate-html-with-pivot.test.mjs (2) 1271ms
   ✓ HTML Pivot Translations (2) 1271ms
     ✓ (es -> fr): Translate "<b>El perro</b> azul." 610ms
     ✓ (fr -> es): Translate "<b>Le chien</b> bleu." 660ms
 ✓ test-cases/translate-plain-text-no-pivot.test.mjs (4) 1601ms
   ✓ Plain-Text Non-Pivot Translations (4) 1601ms
     ✓ (es -> en): Translate "Hola mundo" 384ms
     ✓ (en -> es): Translate "Hello world" 415ms
     ✓ (fr -> en): Translate "Bonjour le monde" 414ms
     ✓ (en -> fr): Translate "Hello world" 387ms
 ✓ test-cases/translate-plain-text-with-pivot.test.mjs (2) 1263ms
   ✓ Plain-Text Pivot Translations (2) 1263ms
     ✓ (es -> fr): Translate "El perro azul." 592ms
     ✓ (fr -> es): Translate "Le chien bleu." 671ms

 Test Files  4 passed (4)
      Tests  12 passed (12)
   Start at  12:32:46
   Duration  1.94s (transform 42ms, setup 0ms, collect 98ms, tests 5.71s, environment 1ms, prepare 230ms)


✅ test-wasm.py completed successfully.

But if you look at the link you pasted for the logs, the output from anything related to node is inserted above the entire Python script's output:

[task 2024-11-12T23:02:55.451Z] (node:8372) ExperimentalWarning: CommonJS module /builds/worker/.nvm/versions/node/v23.1.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /builds/worker/.nvm/versions/node/v23.1.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
[task 2024-11-12T23:02:55.451Z] Support for loading ES Module in require() is an experimental feature and might change at any time
[task 2024-11-12T23:02:55.451Z] (Use `node --trace-warnings ...` to show where the warning was created)
[task 2024-11-12T23:02:57.257Z] 
[task 2024-11-12T23:02:57.257Z] added 134 packages, and audited 135 packages in 2s
[task 2024-11-12T23:02:57.258Z] 
[task 2024-11-12T23:02:57.258Z] 38 packages are looking for funding
[task 2024-11-12T23:02:57.258Z]   run `npm fund` for details
[task 2024-11-12T23:02:57.259Z] 
[task 2024-11-12T23:02:57.259Z] found 0 vulnerabilities
[task 2024-11-12T23:02:57.385Z] 
[task 2024-11-12T23:02:57.385Z] > [email protected] test
[task 2024-11-12T23:02:57.385Z] > vitest --run
[task 2024-11-12T23:02:57.385Z] 
[task 2024-11-12T23:02:57.697Z] 
[task 2024-11-12T23:02:57.697Z]  RUN  v2.1.4 /builds/worker/checkouts/vcs/inference/wasm/tests
[task 2024-11-12T23:02:57.697Z] 
[task 2024-11-12T23:02:59.706Z]  ✓ test-cases/translate-plain-text-with-pivot.test.mjs  (2 tests) 1715ms
[task 2024-11-12T23:02:59.706Z]    ✓ Plain-Text Pivot Translations > (es -> fr): Translate "El perro azul." 853ms
[task 2024-11-12T23:02:59.706Z]    ✓ Plain-Text Pivot Translations > (fr -> es): Translate "Le chien bleu." 860ms
[task 2024-11-12T23:02:59.758Z]  ✓ test-cases/translate-html-with-pivot.test.mjs  (2 tests) 1768ms
[task 2024-11-12T23:02:59.759Z]    ✓ HTML Pivot Translations > (es -> fr): Translate "<b>El perro</b> azul." 882ms
[task 2024-11-12T23:02:59.759Z]    ✓ HTML Pivot Translations > (fr -> es): Translate "<b>Le chien</b> bleu." 885ms
[task 2024-11-12T23:03:00.093Z]  ✓ test-cases/translate-plain-text-no-pivot.test.mjs  (4 tests) 2103ms
[task 2024-11-12T23:03:00.093Z]    ✓ Plain-Text Non-Pivot Translations > (es -> en): Translate "Hola mundo" 545ms
[task 2024-11-12T23:03:00.093Z]    ✓ Plain-Text Non-Pivot Translations > (en -> es): Translate "Hello world" 515ms
[task 2024-11-12T23:03:00.093Z]    ✓ Plain-Text Non-Pivot Translations > (fr -> en): Translate "Bonjour le monde" 544ms
[task 2024-11-12T23:03:00.093Z]    ✓ Plain-Text Non-Pivot Translations > (en -> fr): Translate "Hello world" 498ms
[task 2024-11-12T23:03:00.129Z]  ✓ test-cases/translate-html-no-pivot.test.mjs  (4 tests) 2136ms
[task 2024-11-12T23:03:00.129Z]    ✓ HTML Non-Pivot Translations > (es -> en): Translate "<b>El perro</b> azul." 549ms
[task 2024-11-12T23:03:00.129Z]    ✓ HTML Non-Pivot Translations > (en -> es): Translate "<b>The blue</b> dog." 555ms
[task 2024-11-12T23:03:00.129Z]    ✓ HTML Non-Pivot Translations > (fr -> en): Translate "<b>Le chien</b> bleu." 532ms
[task 2024-11-12T23:03:00.129Z]    ✓ HTML Non-Pivot Translations > (en -> fr): Translate "<b>The blue</b> dog." 498ms
[task 2024-11-12T23:03:00.152Z] 
[task 2024-11-12T23:03:00.153Z]  Test Files  4 passed (4)
[task 2024-11-12T23:03:00.153Z]       Tests  12 passed (12)
[task 2024-11-12T23:03:00.154Z]    Start at  23:02:57
[task 2024-11-12T23:03:00.154Z]    Duration  2.45s (transform 46ms, setup 0ms, collect 98ms, tests 7.72s, environment 1ms, prepare 325ms)
[task 2024-11-12T23:03:00.154Z] 
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 🚀 Starting build-wasm.py
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 📁 Copying generated build artifacts to the WASM test directory
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z]    Copied the following artifacts to /builds/worker/checkouts/vcs/inference/wasm/tests/generated:
[task 2024-11-12T23:03:00.175Z]      - /builds/worker/checkouts/vcs/inference/build-wasm/bergamot-translator.js
[task 2024-11-12T23:03:00.175Z]      - /builds/worker/checkouts/vcs/inference/build-wasm/bergamot-translator.wasm
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 🔑 Calculating SHA-256 hash of /builds/worker/checkouts/vcs/inference/build-wasm/bergamot-translator.js
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z]    Hash of /builds/worker/checkouts/vcs/inference/build-wasm/bergamot-translator.js written to
[task 2024-11-12T23:03:00.175Z]    /builds/worker/checkouts/vcs/inference/wasm/tests/generated/bergamot-translator.js.sha256
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 📂 Decompressing model files required for WASM testing
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z]    Decompressed models in /builds/worker/checkouts/vcs/inference/wasm/tests/models
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 🔧 Installing npm dependencies for WASM JS tests
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 📊 Running Translations WASM JS tests
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] 
[task 2024-11-12T23:03:00.175Z] ✅ test-wasm.py completed successfully.

I don't know why it's out of order in the taskcluster logs. Maybe just a Taskcluster oddity (cc @bhearsum)?

In any case, once we have more tests, I think it will be harder to miss. It is there, though.


print("\n✅ test-wasm.py completed successfully.\n")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion inference/src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(NOT MSVC)
set(TEST_BINARIES async blocking intgemm-resolve wasm)
foreach(binary ${TEST_BINARIES})
add_executable("${binary}" "${binary}.cpp")
target_link_libraries("${binary}" bergamot-translator)
target_link_libraries("${binary}" bergamot-translator-source)
set_target_properties("${binary}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/")
endforeach(binary)

Expand Down
4 changes: 2 additions & 2 deletions inference/src/tests/units/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ foreach(test ${UNIT_TESTS})
target_include_directories("run_${test}" PRIVATE ${CATCH_INCLUDE_DIR} "${CMAKE_SOURCE_DIR}/src")

if(CUDA_FOUND)
target_link_libraries("run_${test}" ${EXT_LIBS} marian ${EXT_LIBS} marian_cuda ${EXT_LIBS} Catch bergamot-translator)
target_link_libraries("run_${test}" ${EXT_LIBS} marian ${EXT_LIBS} marian_cuda ${EXT_LIBS} Catch bergamot-translator-source)
else(CUDA_FOUND)
target_link_libraries("run_${test}" marian ${EXT_LIBS} Catch bergamot-translator)
target_link_libraries("run_${test}" marian ${EXT_LIBS} Catch bergamot-translator-source)
endif(CUDA_FOUND)

if(msvc)
Expand Down
Loading