Unverified Commit 47a54b57 by justadudewhohacks Committed by GitHub

Merge pull request #69 from bmaguireibm/master

Adding support for external model uris
parents f81d35ad 35b8913f
......@@ -16,6 +16,8 @@ export function getModelUris(uri: string | undefined, defaultModelName: string)
manifestUri: `/${defaultManifestFilename}`
}
}
const protocol = uri.startsWith('http://') ? 'http://' : uri.startsWith('https://') ? 'https://' : '';
uri = uri.replace(protocol, '');
const parts = uri.split('/').filter(s => s)
......@@ -23,7 +25,7 @@ export function getModelUris(uri: string | undefined, defaultModelName: string)
? parts[parts.length - 1]
: defaultManifestFilename
let modelBaseUri = (uri.endsWith('.json') ? parts.slice(0, parts.length - 1) : parts).join('/')
let modelBaseUri = protocol + (uri.endsWith('.json') ? parts.slice(0, parts.length - 1) : parts).join('/')
modelBaseUri = uri.startsWith('/') ? `/${modelBaseUri}` : modelBaseUri
return {
......
......@@ -59,6 +59,14 @@ describe('loadWeightMap', () => {
expect(result.modelBaseUri).toEqual('/path/to/modelfiles')
})
it('returns correct uris, given external path', () => {
const uri = 'https://example.com/path/to/modelfiles/';
const result = getModelUris(uri, FAKE_DEFAULT_MODEL_NAME)
expect(result.manifestUri).toEqual(uri + 'model-weights_manifest.json')
expect(result.modelBaseUri).toEqual(uri)
})
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment