Skip to content

Commit

Permalink
Almost finished; removing the last bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff McMillen authored and Jeff McMillen committed Nov 18, 2024
1 parent 0b42c8e commit 0eda545
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 37 deletions.
29 changes: 19 additions & 10 deletions client/src/hooks/datafiles/mutations/useExtract.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { useMutation } from '@tanstack/react-query';
import { useSelector, useDispatch, shallowEqual } from 'react-redux';
import { getCompressParams } from 'utils/getCompressParams';
// import { getCompressParams } from 'utils/getCompressParams';
import { getExtractParams } from 'utils/getExtractParams';
import { apiClient } from 'utils/apiClient';
import { fetchUtil } from 'utils/fetchUtil';
import {
TTapisSystem,
TAppFileInput,
TTapisJob,
TJobArgSpecs,
TJobKeyValuePair,
TTapisFile,
TPortalSystem,
} from 'utils/types';
// import { useCallback } from 'react';
import { fetchAppDefinitionUtil } from 'redux/sagas/apps.sagas';
import { string } from 'prop-types';
import { fetchAppDefinitionUtil } from '../../../redux/sagas/apps.sagas';
import { parseAst } from 'vite';

export type TJobPostOperations = 'resubmitJob' | 'cancelJob' | 'submitJob';

Expand Down Expand Up @@ -93,17 +92,25 @@ function useExtract() {
);

const defaultAllocation = useSelector(
(state: any) => state.allocation.portal_alloc || state.allocation.active[0].projectName
(state: any) => state.allocations.portal_alloc || state.allocations.active[0].projectName
);

const latestExtract = fetchAppDefinitionUtil(extractApp);

const getAppUtil = async function fetchAppDefinitionUtil(appId: string, appVersion: string) {
const params = { appId, appVersion };
const result = await fetchUtil({
url: '/api/workspace/apps',
params,
});
return result.response;
}
const latestExtract = getAppUtil(extractApp.id, extractApp.version);

const { mutate } = useMutation({ mutationFn: submitJobUtil });

const extract = ({
file,
}: {
file: TTapisFile
file: TTapisFile;
}) => {
dispatch({
type: 'DATA_FILES_SET_OPERATION_STATUS',
Expand All @@ -112,9 +119,11 @@ function useExtract() {

const params = getExtractParams(
file,
extractApp,
latestExtract,
defaultAllocation
);
console.log(params);

mutate(
{
Expand All @@ -140,7 +149,7 @@ function useExtract() {
dispatch({
type: 'ADD_TOAST',
payload: {
message: 'Files successfully extracted',
message: 'File extraction in progress',
},
});
dispatch({
Expand Down
66 changes: 40 additions & 26 deletions client/src/utils/getExtractParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,54 @@ import { TTapisFile } from './types';

export const getExtractParams = (
file: TTapisFile,
extractApp: {
id: string;
version: string;
// definition: {
// jobAttributes: {
// execSystemId: string;
// }
// }
},
latestExtract: any,
defaultAllocation: string
defaultAllocation: string,
) => {
const inputFile = `tapis://${file.system}/${file.path}`;
const archivePath = `${file.path.slice(0, -file.name.length)}`;
console.log(extractApp);
console.log(extractApp.id);
console.log(extractApp.version);
// console.log(extractApp.definition);
console.log(latestExtract);
console.log(latestExtract.definition);

return {
job: {
fileInputs: [
fileInputs: [
{
name: 'Input File',
sourceUrl: inputFile,
},
],
name: `${extractApp.id}-${
extractApp.version
}_${new Date().toISOString().split('.')[0]}`,
archiveSystemId: file.system,
archiveSystemDir: archivePath,
archiveOnAppError: false,
appId: extractApp.id,
appVersion: extractApp.version,
parameterSet: {
appArgs: [],
schedulerOptions: [
{
name: 'Input File',
sourceUrl: inputFile,
name: 'TACC Allocation',
description:
'The TACC allocation associated with this job execution',
include: true,
arg: `-A ${defaultAllocation}`,
},
],
name: `${latestExtract.definition.id}-${
latestExtract.definition.version
}_${new Date().toISOString().split('.')[0]}`,
archiveSystemId: file.system,
archiveSystemDir: archivePath,
archiveOnAppError: false,
appId: latestExtract.definition.id,
appVersion: latestExtract.definition.version,
parameterSet: {
appArgs: [],
schedulerOptions: [
{
name: 'TACC Allocation',
description:
'The TACC allocation associated with this job execution',
include: true,
arg: `-A ${defaultAllocation}`,
},
],
},
execSystemId: latestExtract.definition.jobAttributes.execSystemId,
},
execSystemId: latestExtract.definition.jobAttributes.execSystemId,
};
};
2 changes: 2 additions & 0 deletions server/portal/apps/workspace/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,11 @@ def post(self, request, *args, **kwargs):
job_post['archiveSystemDir'] = f'{homeDir}/tapis-jobs-archive/${{JobCreateDate}}/${{JobName}}-${{JobUUID}}'

execSystemId = job_post.get("execSystemId")
print('Marker 1: ',execSystemId)
if not execSystemId:
app = _get_app(job_post["appId"], job_post["appVersion"], request.user)
execSystemId = app["definition"].jobAttributes.execSystemId
print('Marker 2: ',execSystemId)

# Check for and set license environment variable if app requires one
lic_type = body.get('licenseType')
Expand Down
2 changes: 1 addition & 1 deletion server/portal/settings/settings_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
},
"extractApp": {
"id": "extract",
"version": "0.0.3"
"version": "0.0.1"
},
"makePublic": True,
"hideApps": False,
Expand Down

0 comments on commit 0eda545

Please sign in to comment.