Skip to content

Commit

Permalink
fix(single_job): fix multiple minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
soofstad committed Oct 12, 2023
1 parent b26eeb1 commit e00ef4a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,18 @@
"config": {
"type": "PLUGINS:dm-core-plugins/job/JobConfig",
"jobTargetAddress": {
"type": "PLUGINS:dm-core-plugins/job/JobTargetAddress",
"jobAddress": ".job",
"jobAddressScope": "local"
"type": "PLUGINS:dm-core-plugins/job/TargetAddress",
"address": ".job",
"addressScope": "local"
},
"label": "signal job",
"runner": {
"type": "dmss://DemoDataSource/apps/MySignalApp/models/SignalGeneratorJob"
},
"outputTarget": ".signal",
"jobInput": {
"type": "PLUGINS:dm-core-plugins/job/JobInput",
"_type": "dmss://system/SIMOS/Reference",
"referenceType": "link",
"jobInputAddress": ".study.cases[0]",
"jobInputAddressScope": "local"
"type": "PLUGINS:dm-core-plugins/job/TargetAddress",
"address": "."
}
}
},
Expand Down
1 change: 1 addition & 0 deletions example/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
MONGO_INITDB_ROOT_PASSWORD: xd7wCEhEx4kszsecYFfC
SECRET_KEY: sg9aeUM5i1JO4gNN8fQadokJa3_gXQMLBjSGGYcfscs= # Don't reuse this in production...
DATA_SOURCE_FILES: '{ "name": "system", "repositories": { "db": { "type": "mongo-db", "host": "db", "port": 27017, "username": "root", "password": "xd7wCEhEx4kszsecYFfC", "tls": false, "database": "DMSS-core", "collection": "DMSS-core" } }}'
RESET_DATA_SOURCE: off
# volumes:
# - ../../data-modelling-storage-service/src:/code/src
ports:
Expand Down
7 changes: 4 additions & 3 deletions packages/dm-core-plugins/blueprints/job/JobConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
{
"name": "outputTarget",
"type": "CORE:BlueprintAttribute",
"attributeType": "string"
"attributeType": "string",
"optional": true
},
{
"name": "label",
Expand All @@ -26,12 +27,12 @@
{
"name": "jobTargetAddress",
"type": "CORE:BlueprintAttribute",
"attributeType": "PLUGINS:dm-core-plugins/job/JobTargetAddress"
"attributeType": "PLUGINS:dm-core-plugins/job/TargetAddress"
},
{
"name": "jobInput",
"type": "CORE:BlueprintAttribute",
"attributeType": "PLUGINS:dm-core-plugins/job/JobInput"
"attributeType": "PLUGINS:dm-core-plugins/job/TargetAddress"
}
]
}
34 changes: 0 additions & 34 deletions packages/dm-core-plugins/blueprints/job/JobInput.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "JobTargetAddress",
"name": "TargetAddress",
"type": "CORE:Blueprint",
"description": "",
"attributes": [
Expand All @@ -9,12 +9,14 @@
"attributeType": "string"
},
{
"name": "jobAddressScope",
"name": "addressScope",
"type": "CORE:BlueprintAttribute",
"attributeType": "string"
"attributeType": "string",
"optional": true,
"default": "local"
},
{
"name": "jobAddress",
"name": "address",
"type": "CORE:BlueprintAttribute",
"attributeType": "string"
}
Expand Down
60 changes: 29 additions & 31 deletions packages/dm-core-plugins/src/job/JobPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
IUIPlugin,
JobStatus,
splitAddress,
TGenericObject,
TJob,
TJobHandler,
useDMSS,
useJob,
} from '@development-framework/dm-core'
Expand All @@ -24,49 +26,45 @@ const JobButtonWrapper = styled.div`
gap: 8px;
`

interface ITargetAddress {
address: string
addressScope?: 'local' | 'global'
}

interface JobPluginConfig {
jobTargetAddress: {
type: string
jobAddress: string
jobAddressScope: string
}
jobTargetAddress: ITargetAddress
label: string
runner: {
type: string
}
runner: TJobHandler
outputTarget: string
jobInput: {
type: string
_type: string
referenceType: string
jobInputAddress: string
jobInputAddressScope: string
}
jobInput: ITargetAddress
}

export const JobPlugin = (props: IUIPlugin) => {
export const JobPlugin = (props: IUIPlugin & { config: JobPluginConfig }) => {
const {
config,
idReference,
}: { config?: JobPluginConfig; idReference: string } = props
}: { config: JobPluginConfig; idReference: string } = props
const DmssApi = useDMSS()
const defaultTargetOutput = idReference + config?.outputTarget

const jobTargetAddress = (): string => {
if (config?.jobTargetAddress.jobAddressScope === 'local') {
return idReference + config?.jobTargetAddress.jobAddress
if (config.jobTargetAddress.addressScope !== 'local') {
return config.jobTargetAddress.address
}
if (['self', '.'].includes(config?.jobTargetAddress.address)) {
return idReference
}
return config?.jobTargetAddress.jobAddress ?? ''
return idReference + config.jobTargetAddress.address
}

const jobInputAddress = (): string | undefined => {
if (config?.jobInput.jobInputAddressScope === 'local') {
const { dataSource, documentPath } = splitAddress(idReference)
return `dmss://${dataSource}/${documentPath}${config?.jobInput.jobInputAddress}`
const jobInputAddress = (): string => {
if (config.jobInput.addressScope !== 'local') {
return config.jobInput.address
}
if (['self', '.'].includes(config.jobInput.address)) {
return idReference
}
return config?.jobInput.jobInputAddress
return idReference + config.jobInput.address
}
console.log(jobInputAddress())
const { tokenData } = useContext(AuthContext)
const username = tokenData?.preferred_username

Expand All @@ -90,18 +88,18 @@ export const JobPlugin = (props: IUIPlugin) => {
label: config?.label,
type: EBlueprint.JOB,
status: JobStatus.NotStarted,
triggeredBy: username ?? 'unknown user', // TODO: Add propper fallback
triggeredBy: username ?? 'unknown user', // TODO: Add proper fallback
applicationInput: {
type: config?.jobInput._type,
referenceType: config?.jobInput.referenceType,
type: EBlueprint.REFERENCE,
referenceType: 'link',
address: jobInputAddress(),
},
runner: config?.runner,
}

const jobEntityFormData = {
...jobEntity,
outputTarget: defaultTargetOutput,
outputTarget: config?.outputTarget,
}

const updateDocument = async (
Expand Down

0 comments on commit e00ef4a

Please sign in to comment.