Skip to content

Commit

Permalink
Button indicates pipeline registration error
Browse files Browse the repository at this point in the history
  • Loading branch information
vanessavmac committed Jan 19, 2025
1 parent 114718e commit fb0539a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 40 deletions.
14 changes: 4 additions & 10 deletions ami/ml/models/processing_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class Meta:
def create_pipelines(self):
# Call the status endpoint and get the pipelines/algorithms
resp = self.get_status()
if resp.error:
resp.raise_for_status()

pipelines_to_add = resp.pipeline_configs
pipelines = []
pipelines_created = []
Expand Down Expand Up @@ -99,16 +102,7 @@ def get_status(self):
first_response_time = time.time()
latency = first_response_time - start_time

return ProcessingServiceStatusResponse(
timestamp=timestamp,
request_successful=False,
server_live=False,
pipelines_online=[],
pipeline_configs=[],
endpoint_url=self.endpoint_url,
error=error,
latency=latency,
)
return ProcessingServiceStatusResponse(error=error)

pipeline_configs = resp.json()
server_live = requests.get(urljoin(self.endpoint_url, "livez")).json().get("status")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import { usePopulateProcessingService } from 'data-services/hooks/processing-services/usePopulateProcessingService'
import { ProcessingService } from 'data-services/models/processing-service'
import { Button, ButtonTheme } from 'design-system/components/button/button'
import { useState } from 'react'
import { IconType } from 'design-system/components/icon/icon'
import { Tooltip } from 'design-system/components/tooltip/tooltip'
import { STRING, translate } from 'utils/language'

export const PopulateProcessingService = ({
processingService,
}: {
processingService: ProcessingService
}) => {
const [timestamp, setTimestamp] = useState<string>()
const { populateProcessingService: populateProcessingService, isLoading } =
const { populateProcessingService, isLoading, error } =
usePopulateProcessingService()

// TODO: It would be better to inspect task status here, but we currently don't have this information.
const isPopulating =
isLoading || timestamp === processingService.updatedAtDetailed

return (
<Button
label={translate(STRING.REGISTER_PIPELINES)}
loading={isPopulating}
disabled={isPopulating}
theme={ButtonTheme.Success}
onClick={() => {
populateProcessingService(processingService.id)
setTimestamp(processingService.updatedAtDetailed)
}}
/>
<Tooltip
content={
error
? 'Could not register the pipelines, please check the endpoint URL.'
: undefined
}
>
<Button
disabled={isLoading}
label={translate(STRING.REGISTER_PIPELINES)}
icon={error ? IconType.Error : undefined}
loading={isLoading}
onClick={() => populateProcessingService(processingService.id)}
theme={error ? ButtonTheme.Error : ButtonTheme.Success}
/>
</Tooltip>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,6 @@ export const columns: (
<BasicTableCell value={item.num_piplines_added} />
),
},
{
id: 'processing-service-actions',
name: '',
styles: {
padding: '16px',
width: '100%',
},
renderCell: (item: ProcessingService) => (
<div className={styles.entityActions}>
<PopulateProcessingService processingService={item} />
</div>
),
},
{
id: 'actions',
name: '',
Expand All @@ -82,6 +69,7 @@ export const columns: (
},
renderCell: (item: ProcessingService) => (
<div className={styles.entityActions}>
{<PopulateProcessingService processingService={item} />}
{item.canUpdate && (
<UpdateEntityDialog
collection={API_ROUTES.PROCESSING_SERVICES}
Expand Down

0 comments on commit fb0539a

Please sign in to comment.