Skip to content

Commit

Permalink
Updated number 3 for better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
MSeal committed Nov 18, 2022
1 parent 1cb4729 commit 6f076e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const exec = __importStar(require("@actions/exec"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
function findNestedObj(obj, keys) {
keys.reduce((o, key) => o && typeof o[key] !== 'undefined' ? o[key] : undefined, obj);
return keys.reduce((o, key) => o && typeof o[key] !== 'undefined' ? o[key] : undefined, obj);
}
// These are added run actions using "env:"
let runner = JSON.parse(process.env.RUNNER || "");
Expand Down Expand Up @@ -92,6 +92,11 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
from time import sleep
logging.basicConfig(level=logging.INFO, format="%(message)s")
# TODO: Figure out why the basic config isn't setting the defaults for structlog
import structlog
structlog.configure(
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
)
params = {}
paramsPath = '${paramsFile}'
Expand Down Expand Up @@ -154,8 +159,10 @@ for task in as_completed(results):
}
finally {
const notebookObj = JSON.parse(fs.readFileSync(parsedNotebookFile, 'utf8'));
const executionURL = findNestedObj(notebookObj, ["metadata", "executed_notebook_url"]);
yield exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
const executionURL = notebookObj.metadata.executed_notebook_url;
if (executionURL) {
yield exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
}
}
});
}
Expand Down
13 changes: 10 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface IGithubContext {
}

function findNestedObj(obj, keys) {
keys.reduce((o, key) => o && typeof o[key] !== 'undefined' ? o[key] : undefined, obj)
return keys.reduce((o, key) => o && typeof o[key] !== 'undefined' ? o[key] : undefined, obj)
}

// These are added run actions using "env:"
Expand Down Expand Up @@ -77,6 +77,11 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
from time import sleep
logging.basicConfig(level=logging.INFO, format="%(message)s")
# TODO: Figure out why the basic config isn't setting the defaults for structlog
import structlog
structlog.configure(
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
)
params = {}
paramsPath = '${paramsFile}'
Expand Down Expand Up @@ -139,8 +144,10 @@ for task in as_completed(results):
core.setFailed((error as any).message);
} finally {
const notebookObj = JSON.parse(fs.readFileSync(parsedNotebookFile, 'utf8'));
const executionURL = findNestedObj(notebookObj, ["metadata", "executed_notebook_url"])
await exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
const executionURL = notebookObj.metadata.executed_notebook_url;
if (executionURL) {
await exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
}
}
}

Expand Down

0 comments on commit 6f076e6

Please sign in to comment.