Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
xenova committed Sep 9, 2024
1 parent 2f680ee commit 2f9b2ed
Show file tree
Hide file tree
Showing 22 changed files with 2,797 additions and 1,033 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:
- reopened
- synchronize
- ready_for_review
env:
TESTING_REMOTELY: true

jobs:
build:
Expand All @@ -32,11 +30,9 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: pip install -r tests/requirements.txt

# Setup the testing environment
- run: npm run generate-tests
- run: git lfs install && GIT_CLONE_PROTECTION_ACTIVE=false git clone https://huggingface.co/Xenova/t5-small ./models/t5-small
- run: git lfs install && GIT_CLONE_PROTECTION_ACTIVE=false git clone https://huggingface.co/hf-internal-testing/tiny-random-T5ForConditionalGeneration ./models/hf-internal-testing/tiny-random-T5ForConditionalGeneration

# Actually run tests
- run: npm run test
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"typegen": "tsc ./src/transformers.js --allowJs --declaration --emitDeclarationOnly --declarationMap --outDir types",
"dev": "webpack serve --no-client-overlay",
"build": "webpack && npm run typegen",
"generate-tests": "python -m tests.generate_tests",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --maxConcurrency 1",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --verbose --maxConcurrency 1 --runInBand",
"readme": "python ./docs/scripts/build_readme.py",
"docs-api": "node ./docs/scripts/generate.js",
"docs-preview": "doc-builder preview transformers.js ./docs/source/ --not_python_module",
Expand Down
24 changes: 13 additions & 11 deletions tests/configs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

import { AutoConfig, env } from '../src/transformers.js';
import { getFile } from '../src/utils/hub.js';
import { m } from './init.js';

// Initialise the testing environment
env.allowLocalModels=false;
env.useFSCache=false;
env.allowLocalModels = false;
env.useFSCache = false;

// Load test data generated by the python tests
// TODO do this dynamically?
let testsData = await (await getFile('./tests/data/config_tests.json')).json()
const TEST_DATA = {
'Xenova/bert-base-uncased': {
model_type: 'bert',
},
}

describe('Configs', () => {

for (let [configName, targetConfig] of Object.entries(testsData)) {
for (const [model_id, minimal_config] of Object.entries(TEST_DATA)) {

it(configName, async () => {
let config = await AutoConfig.from_pretrained(m(configName));
expect(config.model_type).toEqual(targetConfig.model_type);
expect(config.is_encoder_decoder).toEqual(targetConfig.is_encoder_decoder);
it(model_id, async () => {
const config = await AutoConfig.from_pretrained(model_id);
for(const [key, value] of Object.entries(minimal_config)) {
expect(config[key]).toEqual(value);
}
});
}
});
3 changes: 0 additions & 3 deletions tests/data/.gitignore

This file was deleted.

Loading

0 comments on commit 2f9b2ed

Please sign in to comment.