Skip to content

Commit

Permalink
Fix/beta 3 extractions list (#1199)
Browse files Browse the repository at this point in the history
* Pass file and dataset id from ExtractionHistoryTab into ExtractionJobs to fix rendering of extraction events bugs.

* Fixed message if visualization fails to load.

* Cleaned up ExtractionHistoryTab.tsx and ExtractionJobs.tsx.

* Simplified table row definition in ExtractionJobs.tsx.

* Removed mapping useEffect in ExtractionJobs.tsx.

* Set memory limits for elasticsearch in dev mode to see if it
avoids random startup failures on macs.

* Fixed PydanticObjectId import.

* Fixed duration printing in extraction log.

* Fixed label.

* Fixed refresh button on listing of extraction events.

* Fixed extraction count on listing of extraction events.
  • Loading branch information
lmarini authored Nov 5, 2024
1 parent 1712540 commit f8588a7
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 239 deletions.
2 changes: 1 addition & 1 deletion backend/message_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
EventListenerJobStatus,
EventListenerJobUpdateDB,
)
from bson import ObjectId
from beanie import PydanticObjectId

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ services:
environment:
- cluster.name=clowder2
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- xpack.security.enabled=false
- xpack.security.http.ssl.enabled=false
- http.cors.allow-origin='*'
Expand Down
138 changes: 16 additions & 122 deletions frontend/src/components/listeners/ExtractionHistoryTab.tsx
Original file line number Diff line number Diff line change
@@ -1,148 +1,42 @@
import React, { useEffect, useState } from "react";

import { useDispatch, useSelector } from "react-redux";
import { RootState } from "../../types/data";
import { useDispatch } from "react-redux";
import { fetchListenerJobs } from "../../actions/listeners";
import { ExtractionJobs } from "./ExtractionJobs";
import { format } from "date-fns";
import { parseDate } from "../../utils/common";

const createData = (
status: string,
jobId: string,
listener_id: string,
created: string,
creator: string,
duration: number
) => {
return {
status,
listener_id,
jobId,
created,
creator,
duration,
};
};

const headCells = [
{
id: "status",
label: "",
},
{
id: "listener_id",
label: "Extractor Name",
},
{
id: "jobId",
label: "Job ID",
},
{
id: "created",
label: "Submitted At",
},
{
id: "creator",
label: "Submitted By",
},
{
id: "duration",
label: "Duration",
},
];
export const ExtractionHistoryTab = (props): JSX.Element => {
const { datasetId, fileId } = props;

const dispatch = useDispatch();
const listListenerJobs = (
listenerId: string | null,
status: string | null,
userId: string | null,
fileId: string | null,
datasetId: string | null,
created: string | null,
skip: number,
limit: number
) =>
dispatch(
fetchListenerJobs(
listenerId,
status,
userId,
fileId,
datasetId,
created,
skip,
limit
)
);

const jobs = useSelector((state: RootState) => state.listener.jobs);

const [executionJobsTableRow, setExecutionJobsTableRow] = useState([]);
const [selectedStatus, setSelectedStatus] = useState(null);
const [selectedCreatedTime, setSelectedCreatedTime] = useState(null);

useEffect(() => {
listListenerJobs(
null,
null,
null,
fileId ? fileId : null,
datasetId ? datasetId : null,
null,
0,
100
);
}, []);

const handleRefresh = () => {
listListenerJobs(
null,
selectedStatus,
null,
fileId ? fileId : null,
datasetId ? datasetId : null,
selectedCreatedTime ? format(selectedCreatedTime, "yyyy-MM-dd") : null,
0,
100
);
};

useEffect(() => {
// TODO add pagination for jobs
handleRefresh();
}, [selectedStatus, selectedCreatedTime]);

useEffect(() => {
const rows = [];
if (jobs.length > 0) {
jobs.map((job) => {
rows.push(
createData(
job["status"],
job["id"],
job["listener_id"],
parseDate(job["created"]),
job["creator"]["email"],
`${job["duration"]} sec`
)
);
});
}
setExecutionJobsTableRow(rows);
}, [jobs]);
dispatch(
fetchListenerJobs(
null,
selectedStatus,
null,
fileId,
datasetId,
selectedCreatedTime ? format(selectedCreatedTime, "yyyy-MM-dd") : null,
0,
100
)
);
}, [selectedStatus, selectedCreatedTime, dispatch]);

return (
<ExtractionJobs
rows={executionJobsTableRow}
headCells={headCells}
selectedStatus={selectedStatus}
selectedCreatedTime={selectedCreatedTime}
setSelectedStatus={setSelectedStatus}
setSelectedCreatedTime={setSelectedCreatedTime}
handleRefresh={handleRefresh}
fileId={fileId}
datasetId={datasetId}
/>
);
};
Loading

0 comments on commit f8588a7

Please sign in to comment.