Skip to content

Commit

Permalink
Release/next (#881)
Browse files Browse the repository at this point in the history
* fix: wrong formatting of run complete time (#878)

* fix: wrong formatting of run complete time

logger.timer already returns a better human readable time string.

* changeset

---------

Co-authored-by: Joe Clark <[email protected]>

* Fix worker log level (#880)

* ensure the jobLogLevel option gets properly fed through to the worker

* fix integration test and tidy logging

* version: [email protected] [email protected]

* worker: remove debug code

---------

Co-authored-by: Farhan Y. <[email protected]>
  • Loading branch information
josephjclark and doc-han authored Feb 25, 2025
1 parent 1a0a712 commit b4f0f12
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 25 deletions.
7 changes: 7 additions & 0 deletions integration-tests/execute/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/integration-tests-execute

## 1.0.17

### Patch Changes

- Updated dependencies [2667710]
- @openfn/runtime@1.6.3

## 1.0.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/execute/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openfn/integration-tests-execute",
"private": true,
"version": "1.0.16",
"version": "1.0.17",
"description": "Job execution tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
10 changes: 10 additions & 0 deletions integration-tests/worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @openfn/integration-tests-worker

## 1.0.78

### Patch Changes

- Updated dependencies [d430258]
- Updated dependencies [2667710]
- @openfn/engine-multi@1.5.1
- @openfn/ws-worker@1.11.1
- @openfn/lightning-mock@2.1.1

## 1.0.77

### 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.77",
"version": "1.0.78",
"description": "Lightning WOrker integration tests",
"author": "Open Function Group <[email protected]>",
"license": "ISC",
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/worker/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import createLightningServer, { toBase64 } from '@openfn/lightning-mock';
import createEngine from '@openfn/engine-multi';
import createWorkerServer from '@openfn/ws-worker';
import { createMockLogger } from '@openfn/logger';
import createLogger from '@openfn/logger';
// import createLogger from '@openfn/logger';

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

Expand Down Expand Up @@ -39,8 +39,8 @@ export const initWorker = async (
});

const worker = createWorkerServer(engine, {
// logger: createMockLogger(),
logger: createLogger('worker', { level: 'debug' }),
logger: createMockLogger(),
// logger: createLogger('worker', { level: 'debug' }),
port: workerPort,
lightning: `ws://localhost:${lightningPort}/worker`,
secret: crypto.randomUUID(),
Expand Down
24 changes: 14 additions & 10 deletions integration-tests/worker/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,19 +996,23 @@ test.serial(
},
};

const jobLogs = [];
const rtLogs = [];

lightning.on('run:log', (e) => {
if (e.payload.source === 'JOB') {
jobLogs.push(e.payload);
} else if (e.payload.source === 'R/T') {
rtLogs.push(e.payload);
}
});

lightning.once('run:complete', () => {
const jsonLogs = engineLogger._history;
// The engine logger shouldn't print out any job logs
const jobLog = jsonLogs.find((l) => l.name === 'JOB');
t.falsy(jobLog);
const jobLog2 = jsonLogs.find((l) => l.message[0] === message);
t.falsy(jobLog2);
// Ensure no run logs got sent back to lightning
t.falsy(jobLogs.length);

// But it SHOULD log engine stuff
const runtimeLog = jsonLogs.find(
(l) => l.name === 'engine' && l.message[0].match(/complete workflow/i)
);
t.truthy(runtimeLog);
t.truthy(rtLogs.length);
done();
});

Expand Down
8 changes: 8 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/cli

## 1.11.3

### Patch Changes

- 2667710: Fix an issue where step completion time is logged with double units (ie, `2msms`)
- Updated dependencies [2667710]
- @openfn/runtime@1.6.3

## 1.11.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/cli",
"version": "1.11.2",
"version": "1.11.3",
"description": "CLI devtools for the openfn toolchain.",
"engines": {
"node": ">=18",
Expand Down
8 changes: 8 additions & 0 deletions packages/engine-multi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# engine-multi

## 1.5.1

### Patch Changes

- d430258: Fix an issue where Lightning log level options don't get fed to the engine properly
- Updated dependencies [2667710]
- @openfn/runtime@1.6.3

## 1.5.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-multi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/engine-multi",
"version": "1.5.0",
"version": "1.5.1",
"description": "Multi-process runtime engine",
"main": "dist/index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/engine-multi/src/api/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const execute = async (context: ExecutionContext) => {
const runOptions = {
statePropsToRemove: options.statePropsToRemove,
whitelist,
jobLogLevel: options.jobLogLevel,
} as RunOptions;

const workerOptions = {
Expand Down Expand Up @@ -108,7 +109,6 @@ const execute = async (context: ExecutionContext) => {
jobError(context, evt);
},
[workerEvents.LOG]: (evt: workerEvents.LogEvent) => {
// console.log(evt.log.name, evt.log.message);
log(context, evt);
},
// TODO this is also untested
Expand Down
1 change: 1 addition & 0 deletions packages/engine-multi/src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const createEngine = async (
resolvers: opts.resolvers,
runTimeoutMs: opts.runTimeoutMs ?? defaultTimeout,
memoryLimitMb: opts.memoryLimitMb ?? defaultMemoryLimit,
jobLogLevel: opts.jobLogLevel,
},
});

Expand Down
5 changes: 2 additions & 3 deletions packages/engine-multi/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ export type ExecuteOptions = {
resolvers?: LazyResolvers;
runTimeoutMs?: number;
sanitize?: SanitizePolicies;
jobLogLevel?: string;
};

export type ExecutionContextOptions = EngineOptions & {
sanitize?: SanitizePolicies;
};
export type ExecutionContextOptions = ExecuteOptions & EngineOptions;

export interface EngineAPI extends EventEmitter {
callWorker: CallWorker;
Expand Down
25 changes: 25 additions & 0 deletions packages/engine-multi/test/api/execute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,28 @@ test.serial('should stringify the whitelist array', async (t) => {
t.truthy(passedOptions);
t.deepEqual(passedOptions.whitelist, ['/abc/']);
});

test.serial('should forward the jobLogLevel option', async (t) => {
let passedOptions: any;

const state = {
id: 'x',
plan,
} as WorkflowState;

const opts = {
...options,
jobLogLevel: 'none',
};

const context = createContext({ state, options: opts });
// @ts-ignore
context.callWorker = (_command, args) => {
passedOptions = args[2];
};

await execute(context);

t.truthy(passedOptions);
t.deepEqual(passedOptions.jobLogLevel, 'none');
});
9 changes: 9 additions & 0 deletions packages/lightning-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @openfn/lightning-mock

## 2.1.1

### Patch Changes

- Updated dependencies [d430258]
- Updated dependencies [2667710]
- @openfn/engine-multi@1.5.1
- @openfn/runtime@1.6.3

## 2.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/lightning-mock/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/lightning-mock",
"version": "2.1.0",
"version": "2.1.1",
"private": true,
"description": "A mock Lightning server",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/runtime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @openfn/runtime

## 1.6.3

### Patch Changes

- 2667710: Fix an issue where step completion time is logged with double units (ie, `2msms`)

## 1.6.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/runtime",
"version": "1.6.2",
"version": "1.6.3",
"description": "Job processing runtime.",
"type": "module",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/src/execute/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const executeStep = async (

if (!didError) {
const humanDuration = logger.timer(timerId);
logger.success(`${jobName} completed in ${humanDuration}ms`);
logger.success(`${jobName} completed in ${humanDuration}`);
result = prepareFinalState(result, logger, ctx.opts.statePropsToRemove);

// Take a memory snapshot
Expand Down
11 changes: 11 additions & 0 deletions packages/ws-worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# ws-worker

## 1.11.1

### Patch Changes

- d430258: Fix an issue where Lightning log level options don't get fed to the engine properly
- 2667710: Fix an issue where step completion time is logged with double units (ie, `2msms`)
- Updated dependencies [d430258]
- Updated dependencies [2667710]
- @openfn/engine-multi@1.5.1
- @openfn/runtime@1.6.3

## 1.11.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ws-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/ws-worker",
"version": "1.11.0",
"version": "1.11.1",
"description": "A Websocket Worker to connect Lightning to a Runtime Engine",
"main": "dist/index.js",
"type": "module",
Expand Down

0 comments on commit b4f0f12

Please sign in to comment.