-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Remove all hard-coded resource slot names in
/react
- Loading branch information
Showing
12 changed files
with
209 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// import json | ||
import deviceMetadata from '../../../resources/device_metadata.json'; | ||
import schema from '../../../resources/device_metadata.schema.json'; | ||
import { | ||
knownAcceleratorResourceSlotNames, | ||
baseResourceSlotNames, | ||
} from './backendai'; | ||
import Ajv from 'ajv'; | ||
import _ from 'lodash'; | ||
|
||
const ajv = new Ajv(); | ||
|
||
describe('deviceMetadata JSON Schema Validation', () => { | ||
it('should include all known accelerator names and base resource names', () => { | ||
Check failure on line 14 in react/src/hooks/backendai.test.tsx GitHub Actions / Tests annotations (🧪 jest-coverage-report-action)deviceMetadata JSON Schema Validation > should include all known accelerator names and base resource names
|
||
const strictSchema = _.cloneDeep(schema); | ||
|
||
// @ts-ignore | ||
strictSchema.properties.deviceInfo.required = [ | ||
...knownAcceleratorResourceSlotNames, | ||
...baseResourceSlotNames, | ||
]; | ||
|
||
const validate = ajv.compile(strictSchema); | ||
const valid = validate(deviceMetadata); | ||
if (!valid) { | ||
console.error(validate.errors); | ||
} | ||
expect(valid).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { isMatchingMaxPerContainer } from './useResourceLimitAndRemaining'; | ||
import exp from 'constants'; | ||
|
||
describe('getConfigName', () => { | ||
test('should match unknown devices', () => { | ||
expect( | ||
isMatchingMaxPerContainer('maxCUDADevicesPerContainer', 'cuda.device'), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer('maxCUDASharesPerContainer', 'cuda.shares'), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer('maxROCMDevicesPerContainer', 'rocm.device'), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer('maxTPUDevicesPerContainer', 'tpu.device'), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer('maxIPUDevicesPerContainer', 'ipu.device'), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer('maxATOMDevicesPerContainer', 'atom.device'), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer( | ||
'maxATOMPLUSDevicesPerContainer', | ||
'atom-plus.device', | ||
), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer( | ||
'maxGaudi2DevicesPerContainer', | ||
'gaudi2.device', | ||
), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer( | ||
'maxWarboyDevicesPerContainer', | ||
'warboy.device', | ||
), | ||
).toBe(true); | ||
expect( | ||
isMatchingMaxPerContainer( | ||
'maxHyperaccelLPUDevicesPerContainer', | ||
'hyperaccel-lpu.device', | ||
), | ||
).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.