Skip to content

Commit

Permalink
Merge pull request #24 from PAIR-code/iislucas-27-aug-2024-fixes
Browse files Browse the repository at this point in the history
Small clarity fixes
  • Loading branch information
iislucas authored Aug 27, 2024
2 parents ec45a30 + ede6d38 commit cd64604
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 104 deletions.
6 changes: 3 additions & 3 deletions animated-transformer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Recommended dependendies:

- Install node `v20.14.0` using the [nvm](https://github.com/nvm-sh/nvm) tool: `$ nvm install v20.14.0`
- Set the default to be this version: `nvm alias default v20.14.0`
- Install globally the Angular 18 CLI with `$ npm install -g @angular/cli`
- Install node `v22` using the [nvm](https://github.com/nvm-sh/nvm) tool: `$ nvm install v22`
- Set the default to be this version: `nvm alias default v22`
- \[optional\] Install globally the Angular 18 CLI with `$ npm install -g @angular/cli` so that you can directly use `ng` commands, otherwise you have to use `npx ng`.

## Development server

Expand Down
3 changes: 2 additions & 1 deletion animated-transformer/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"src/styles.scss"
],
"scripts": [],
"webWorkerTsConfig": "tsconfig.worker.json"
"webWorkerTsConfig": "tsconfig.worker.json",
"karmaConfig": "karma.conf.js"
}
}
}
Expand Down
51 changes: 51 additions & 0 deletions animated-transformer/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/tiny-transformers'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
browsers: ['Chrome'],
restartOnFileChange: true,
proxies: {
'/src/': './src/'
},
files: [
{
pattern: './src/**/*.ts',
watched: true,
included: false,
nocache: true,
served: true,
}
]
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

import { getUniGramTinyWorldConfig } from './generated_tiny_worlds';
import { getUniGramTinyWorldConfig } from './ngram_tiny_worlds';
import { TinyWorldTask } from './tiny_worlds';

describe('generated_tiny_worlds', () => {
describe('ngram_tiny_worlds', () => {
beforeEach(() => {});

it('test_getUniGramTinyWorldConfig', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ limitations under the License.
==============================================================================*/

/* Generated Tiny Worlds */

import * as tf from '@tensorflow/tfjs';
import { TinyWorldTaskConfig } from './tiny_worlds';
import { makeRandomStream } from '../state-iter/random';
import { universalType } from '../logic/relations';
Expand Down
82 changes: 0 additions & 82 deletions animated-transformer/src/lib/seqtasks/one_d_hero_task.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

/*
Tiny Worlds, run with (gtensor-based) transformers.
Run:
npx ts-node src/lib/seqtasks/tiny_worlds.run_with_transformer.script.ts
*/

import * as tf from '@tensorflow/tfjs-node';
Expand Down Expand Up @@ -234,7 +232,7 @@ function run() {

console.log('Inference Step:', inferStep);
console.log('Context:', batchInput[0].join(''));
console.log('Target Output:', batchOutput[0].join(''));
// console.log('Target Output:', batchOutput[0].join(''));
console.log('Target next token:', batchOutput[0][0]);
console.log('Prediction:');
console.log(' ', 'token'.padEnd(10), ' ', 'prob'.padEnd(10), ' ');
Expand Down
2 changes: 1 addition & 1 deletion animated-transformer/src/lib/weblab/cellspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type InputPromises<S extends ValueStruct> = { [Key in keyof S]: Promise<S

export class CellSpec<Inputs extends ValueStruct, Outputs extends ValueStruct> {
constructor(
public workerPath: string,
public workerPath: URL,
public inputs: (keyof Inputs)[],
public outputs: (keyof Outputs)[]
) {}
Expand Down
5 changes: 3 additions & 2 deletions animated-transformer/src/lib/weblab/example.ailab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const globals: Partial<Globals> = {
// } as WorkerOp<'name', 't'>;

export const exampleWorkerSpec = new CellSpec<GlobalValue<'name'>, GlobalValue<'tensor'>>(
'./example.worker',
['name'],
// 'src/lib/weblab/example.worker.js' as never as URL,
new URL('./example.worker', import.meta.url),
['name'], // new URL('http://localhost:9876/_karma_webpack_/example.worker'),
['tensor']
);
9 changes: 2 additions & 7 deletions animated-transformer/src/lib/weblab/lab-env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,15 @@ import { exampleWorkerSpec, Globals } from './example.ailab';

xdescribe('lab-env', () => {
const state = new LabState();
// const ops: OpKind[] = [
// {
// workerpath: './app.worker',
// inputs: ['name'],
// outputs: ['t'],
// },
// ];
beforeEach(async () => {});

it('worker-op', async () => {
const env = new LabEnv<Globals>(state);
env.stateVars.name = 'initial fake name';
const outputs = await env.run(exampleWorkerSpec);
expect(outputs.tensor).toBeTruthy();
});

it('ignoreme', () => {
expect(true).toBeTruthy();
});
Expand Down
7 changes: 6 additions & 1 deletion animated-transformer/src/lib/weblab/lab-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ export class LabEnv<Globals extends ValueStruct> {
}
}

const worker = new Worker(new URL(op.workerPath, import.meta.url));
// const workerUrl = new URL(op.workerUrl, import.meta.url);
// console.log('op.workerPath:', op.workerPath);
// console.log('import.meta.url:', import.meta.url);
// console.log('workerUrl:', workerUrl);
const worker = new Worker(op.workerPath, { type: 'module' });
// console.log(worker);
worker.onmessage = ({ data }) => {
const messageFromWorker = data as FromWorkerMessage;
switch (messageFromWorker.kind) {
Expand Down

0 comments on commit cd64604

Please sign in to comment.