Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
v0.3.0 bump
Browse files Browse the repository at this point in the history
  • Loading branch information
brannondorsey committed Apr 30, 2020
1 parent d6bf099 commit 56ca040
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.3.0

- Add usage section in README.
- More descriptive error message for `NotFoundError`.
- Wake up model during `HostedModel` construction.
- Add optional `pollIntervalMillis` parameter to `HostedModel.waitUntilAwake()` method.

## v0.2.0

- Add CI/CD releases via CircleCI
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@runwayml/hosted-models",
"version": "0.2.0",
"version": "0.3.0",
"description": "Interact with Runway Hosted Models with only a few lines of code!",
"main": "build/index.js",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions src/HostedModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class HostedModel {
if (this.token) this.headers['Authorization'] = `Bearer ${this.token}`;
this.responseCodesToRetry = [502, 429];
if (!this.isValidV1URL(this.url)) throw new InvlaidURLError();
// Wake up the model during construction because it will probably be used soon
this.root()
.then(result => result)
.catch(err => err);
}

/**
Expand Down Expand Up @@ -141,8 +145,11 @@ export class HostedModel {
* doSomething(output)
* }
* ```
*
* @param pollIntervalMillis [[waitUntilAwake]] The rate that this function will poll
* the hosted model endpoint to check if it is awake yet.
*/
async waitUntilAwake(): Promise<void> {
async waitUntilAwake(pollIntervalMillis = 1000): Promise<void> {
return new Promise((resolve, reject) => {
(async () => {
try {
Expand All @@ -152,7 +159,7 @@ export class HostedModel {
resolve();
return;
}
await delay(500);
await delay(pollIntervalMillis);
}
} catch (err) {
reject(err);
Expand Down

0 comments on commit 56ca040

Please sign in to comment.