Skip to content

Commit

Permalink
bug fixes / doc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranMn committed Jan 15, 2025
1 parent 7a8f665 commit c288ebf
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions apps/hash-ai-worker-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The service uses the following environment variables:

### Run the worker

- To use actions which require Google Cloud Platform, you must run `gcloud auth application-default login` before starting the worker.
- Ensure the environment variables above are set, either in `.env.local` or in your shell.
- Install dependencies:
- `yarn`
Expand Down
1 change: 1 addition & 0 deletions apps/hash-ai-worker-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"start:healthcheck": "wait-on --timeout 120000 http-get://localhost:4100/health",
"start:test": "NODE_ENV=test NODE_OPTIONS=--max-old-space-size=2048 node ./dist/main.js",
"start:test:healthcheck": "wait-on --timeout 120000 http-get://localhost:4100/health",
"temporal:clean": "temporal workflow terminate --query \"TaskQueue='ai'\" --reason=\"Batch terminate from CLI\"",
"test:unit": "vitest --run --exclude \"**/*.ai.test.ts\""
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ export const persistEntitiesAction: FlowActionActivity = async ({ inputs }) => {
if (!output) {
failedEntitiesByLocalId[unresolvedEntity.localEntityId] = {
proposedEntity: unresolvedEntity,
message: `No outputs returned when attempting to persist entity`,
message:
persistedEntityOutputs.message ??
`No outputs returned when attempting to persist entity`,
};
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,26 @@ export const persistEntityAction: FlowActionActivity = async ({ inputs }) => {
});

/**
* In practice we don't reassign existingEntity anywhere below it doesn't harm to make sure it will always
* In practice we don't reassign matchedEntityUpdate anywhere below it doesn't harm to make sure it will always
* be the same thing in the backOff function.
*/
const stableReferenceToExistingEntity =
matchedEntityUpdate.existingEntity;
const stableReferenceToMatchedEntity = matchedEntityUpdate;

entity = await backOff(
() =>
stableReferenceToExistingEntity.patch(
stableReferenceToMatchedEntity.existingEntity.patch(
graphApiClient,
{ actorId: webBotActorId },
{
...entityValues,
entityTypeIds:
stableReferenceToMatchedEntity.newValues.entityTypeIds,
draft: existingEntityIsDraft ? true : createEditionAsDraft,
propertyPatches: patchOperations,
provenance: {
...entityValues.provenance,
sources:
stableReferenceToMatchedEntity.newValues.editionSources,
},
},
),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,13 @@ export const findExistingEntity = async ({
},
],
},
limit: 3,
temporalAxes: currentTimeInstantTemporalAxes,
includeDrafts,
})
.then(({ data: response }) =>
response.entities.map((entity) =>
mapGraphApiEntityToEntity(entity, actorId),
),
response.entities
.slice(0, 3)
.map((entity) => mapGraphApiEntityToEntity(entity, actorId)),
);
}

Expand Down Expand Up @@ -253,14 +252,13 @@ export const findExistingEntity = async ({
},
],
},
limit: 3,
temporalAxes: currentTimeInstantTemporalAxes,
includeDrafts,
})
.then(({ data: response }) =>
response.entities.map((entity) =>
mapGraphApiEntityToEntity(entity, actorId),
),
response.entities
.slice(0, 3)
.map((entity) => mapGraphApiEntityToEntity(entity, actorId)),
);
}
}
Expand Down Expand Up @@ -309,7 +307,10 @@ export const findExistingLinkEntity = async ({
{ equal: [{ path: ["archived"] }, { parameter: false }] },
{
any: proposedEntity.entityTypeIds.map((entityTypeId) => ({
equal: [{ path: ["versionedUrl"] }, { parameter: entityTypeId }],
equal: [
{ path: ["type", "versionedUrl"] },
{ parameter: entityTypeId },
],
})),
},
{
Expand Down

0 comments on commit c288ebf

Please sign in to comment.