Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
337 changes: 327 additions & 10 deletions src/rest-server/docs/swagger.yaml

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/rest-server/src/controllers/v2/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ const list = asyncHandler(async (req, res) => {
});

const get = asyncHandler(async (req, res) => {
const data = await job.get(req.params.frameworkName);
const data = await job.get(
req.params.frameworkName,
Number(req.params.jobAttemptId),
);
res.json(data);
});

Expand Down
35 changes: 35 additions & 0 deletions src/rest-server/src/controllers/v2/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// module dependencies
const asyncHandler = require('@pai/middlewares/v2/asyncHandler');
const task = require('@pai/models/v2/task');

const get = asyncHandler(async (req, res) => {
const result = await task.get(
req.params.frameworkName,
Number(req.params.jobAttemptId),
req.params.taskRoleName,
Number(req.params.taskIndex),
);
res.status(result.status).json(result.data);
});

// module exports
module.exports = {
get,
};
18 changes: 1 addition & 17 deletions src/rest-server/src/models/v2/job-attempt.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// module dependencies
const crypto = require('crypto');

const { convertToJobAttempt } = require('@pai/utils/frameworkConverter');
const launcherConfig = require('@pai/config/launcher');
const logger = require('@pai/config/logger');
const databaseModel = require('@pai/utils/dbUtils');

const convertName = (name) => {
// convert framework name to fit framework controller spec
return name.toLowerCase().replace(/[^a-z0-9]/g, '');
};

const encodeName = (name) => {
if (name.startsWith('unknown') || !name.includes('~')) {
// framework is not generated by PAI
return convertName(name.replace(/^unknown/g, ''));
} else {
// md5 hash
return crypto.createHash('md5').update(name).digest('hex');
}
};
const encodeName = require('@pai/utils/name').encodeName;

if (launcherConfig.enabledJobHistory) {
const healthCheck = async () => {
Expand Down
Loading