Skip to content

Commit

Permalink
Merge pull request #579 from OpenFn/rename2
Browse files Browse the repository at this point in the history
finish renaming
  • Loading branch information
taylordowns2000 authored Jan 30, 2024
2 parents c5ace0f + 1021ab2 commit b77d5b1
Show file tree
Hide file tree
Showing 88 changed files with 1,061 additions and 1,099 deletions.
8 changes: 4 additions & 4 deletions docs/future/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ that both transpiles and executes a job based on the following inputs:

## Compilation

The first thing that core does, is attempt to compile an expression.
The first thing that core does is try to compile an expression.
Since we allow users to write function calls
(without having to write require or import statements),
we have to transpile the code to be able to reference the adaptor functions.
Expand Down Expand Up @@ -57,8 +57,8 @@ fn((state) => {
```

The execute function is an async reducer (using vanilla promises,
as async/await and generators were in Stage 0 at the time of implementation).
This pattern allows users to write code that ‘feels’ synchronous but is
as async/await and generators were in Stage 0 at the time of implementation).
This pattern allows users to write code that ‘feels’ synchronous but is
executed asynchronously.

## Execution
Expand All @@ -69,5 +69,5 @@ The execution environment ties all the work together.

It’s important to note that code is executed in a sandboxed environment,
where the vast majority of NodeJS root functionality is not available.
We also check in the compilation step that function calls that are not in
We also check in the compilation step that function calls that are not in
the ‘scope’ of our sandbox and throw errors in these cases.
9 changes: 9 additions & 0 deletions integration-tests/worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @openfn/integration-tests-worker

## 1.0.33

### Patch Changes

- Updated dependencies [7e4c159]
- @openfn/lightning-mock@1.2.0
- @openfn/engine-multi@0.4.0
- @openfn/ws-worker@0.8.0

## 1.0.32

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-worker",
"private": true,
"version": "1.0.32",
"version": "1.0.33",
"description": "Lightning WOrker integration tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/worker/src/factories.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import crypto from 'node:crypto';

export const createAttempt = (triggers, jobs, edges, args = {}) => ({
export const createRun = (triggers, jobs, edges, args = {}) => ({
id: crypto.randomUUID(),
triggers,
jobs,
Expand Down Expand Up @@ -32,4 +32,4 @@ export const createEdge = (a: any, b: any, condition?: string) => {
return edge;
};

export default createAttempt;
export default createRun;
2 changes: 1 addition & 1 deletion integration-tests/worker/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import createEngine from '@openfn/engine-multi';
import createWorkerServer from '@openfn/ws-worker';
import createLogger, { createMockLogger } from '@openfn/logger';

export const randomPort = () => parseInt(2000 + Math.random() * 1000);
export const randomPort = () => Math.round(2000 + Math.random() * 1000);

export const initLightning = (port = 4000) => {
// TODO the lightning mock right now doesn't use the secret
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/worker/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export const run = async (lightning, attempt) => {
return new Promise<any>(async (done, reject) => {
lightning.on('attempt:complete', (evt) => {
if (attempt.id === evt.attemptId) {
lightning.on('run:complete', (evt) => {
if (attempt.id === evt.runId) {
done(lightning.getResult(attempt.id));
} else {
// If we get here, something has gone very wrong
reject('attempt not found');
}
});

lightning.enqueueAttempt(attempt);
lightning.enqueueRun(attempt);
});
};

Expand Down
10 changes: 5 additions & 5 deletions integration-tests/worker/test/autoinstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ import test from 'ava';
import path from 'node:path';

import { initLightning, initWorker } from '../src/init';
import { createAttempt, createJob } from '../src/factories';
import { createRun, createJob } from '../src/factories';

const generate = (adaptor, version) => {
const specifier = `@openfn/language-${adaptor}@${version}`;
const job = createJob({
body: `fn(() => ({ data: "${adaptor}" }))`,
adaptor: specifier,
});
return createAttempt([], [job], []);
return createRun([], [job], []);
};

let lightning;
let worker;

const run = async (attempt) => {
return new Promise<any>(async (done, reject) => {
lightning.on('attempt:complete', (evt) => {
if (attempt.id === evt.attemptId) {
lightning.on('run:complete', (evt) => {
if (attempt.id === evt.runId) {
done(lightning.getResult(attempt.id));
}
});

lightning.enqueueAttempt(attempt);
lightning.enqueueRun(attempt);
});
};

Expand Down
10 changes: 5 additions & 5 deletions integration-tests/worker/test/benchmark.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import path from 'node:path';

import { createAttempt } from '../src/factories';
import { createRun } from '../src/factories';
import { initLightning, initWorker } from '../src/init';
import { run, humanMb } from '../src/util';

Expand Down Expand Up @@ -29,7 +29,7 @@ test.before(async () => {
));

// trigger autoinstall
const bootstrap = createAttempt(
const bootstrap = createRun(
[],
[
{
Expand Down Expand Up @@ -64,7 +64,7 @@ test.serial.skip('run 100 attempts', async (t) => {
const start = Date.now();

for (let i = 0; i < attemptsTotal; i++) {
const attempt = createAttempt(
const attempt = createRun(
[],
[
{
Expand All @@ -85,12 +85,12 @@ test.serial.skip('run 100 attempts', async (t) => {
],
[]
);
lightning.enqueueAttempt(attempt);
lightning.enqueueRun(attempt);
}

lightning.on('step:complete', (evt) => {
// May want to disable this but it's nice feedback
t.log('Completed ', evt.attemptId);
t.log('Completed ', evt.runId);

if (evt.payload.reason !== 'success') {
t.log('Atempt failed:');
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/worker/test/exit-reasons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ test.after(async () => {

const run = async (attempt) => {
return new Promise<any>(async (done) => {
lightning.once('attempt:complete', (evt) => {
if (attempt.id === evt.attemptId) {
lightning.once('run:complete', (evt) => {
if (attempt.id === evt.runId) {
done(evt.payload);
}
});

lightning.enqueueAttempt(attempt);
lightning.enqueueRun(attempt);
});
};

Expand Down
Loading

0 comments on commit b77d5b1

Please sign in to comment.