Skip to content

Commit 6f076e6

Browse files
committed
Updated number 3 for better logging
1 parent 1cb4729 commit 6f076e6

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

lib/main.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const exec = __importStar(require("@actions/exec"));
3737
const fs = __importStar(require("fs"));
3838
const path = __importStar(require("path"));
3939
function findNestedObj(obj, keys) {
40-
keys.reduce((o, key) => o && typeof o[key] !== 'undefined' ? o[key] : undefined, obj);
40+
return keys.reduce((o, key) => o && typeof o[key] !== 'undefined' ? o[key] : undefined, obj);
4141
}
4242
// These are added run actions using "env:"
4343
let runner = JSON.parse(process.env.RUNNER || "");
@@ -92,6 +92,11 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
9292
from time import sleep
9393
9494
logging.basicConfig(level=logging.INFO, format="%(message)s")
95+
# TODO: Figure out why the basic config isn't setting the defaults for structlog
96+
import structlog
97+
structlog.configure(
98+
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
99+
)
95100
96101
params = {}
97102
paramsPath = '${paramsFile}'
@@ -154,8 +159,10 @@ for task in as_completed(results):
154159
}
155160
finally {
156161
const notebookObj = JSON.parse(fs.readFileSync(parsedNotebookFile, 'utf8'));
157-
const executionURL = findNestedObj(notebookObj, ["metadata", "executed_notebook_url"]);
158-
yield exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
162+
const executionURL = notebookObj.metadata.executed_notebook_url;
163+
if (executionURL) {
164+
yield exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
165+
}
159166
}
160167
});
161168
}

src/main.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface IGithubContext {
1515
}
1616

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

2121
// These are added run actions using "env:"
@@ -77,6 +77,11 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
7777
from time import sleep
7878
7979
logging.basicConfig(level=logging.INFO, format="%(message)s")
80+
# TODO: Figure out why the basic config isn't setting the defaults for structlog
81+
import structlog
82+
structlog.configure(
83+
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
84+
)
8085
8186
params = {}
8287
paramsPath = '${paramsFile}'
@@ -139,8 +144,10 @@ for task in as_completed(results):
139144
core.setFailed((error as any).message);
140145
} finally {
141146
const notebookObj = JSON.parse(fs.readFileSync(parsedNotebookFile, 'utf8'));
142-
const executionURL = findNestedObj(notebookObj, ["metadata", "executed_notebook_url"])
143-
await exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
147+
const executionURL = notebookObj.metadata.executed_notebook_url;
148+
if (executionURL) {
149+
await exec.exec(`echo "Notebook run can be found at ${executionURL}"`);
150+
}
144151
}
145152
}
146153

0 commit comments

Comments
 (0)