Skip to content

Commit b4b7e37

Browse files
committed
Issue #135 - add plantNet check into healthCheck
1 parent e30eb21 commit b4b7e37

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

src/config/ApplicationConfig.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ export default class ApplicationConfig {
179179
.addArgument(container.get('config'))
180180
.addArgument(container.get('loggerService'))
181181
.addArgument(container.get('blueskyService'))
182-
.addArgument(container.get('unsplashService'))
182+
.addArgument(container.get('plantnetApiService'))
183183
.addArgument(container.get('pluginsCommonService'))
184-
.addArgument(container.get('grBirdApiService'))
185184
.addArgument(container.get('logsService'));
186185
this.plugins.push(container.get('healthCheck'));
187186
}

src/plugins/HealthCheck.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
export default class HealthCheck {
2-
constructor(config, loggerService, blueskyService, unsplashService,
3-
pluginsCommonService, grBirdApiService, logsService) {
2+
constructor(config, loggerService, blueskyService, plantnetApiService, pluginsCommonService, logsService) {
43
this.isAvailable = false;
54
this.logger = loggerService.getLogger().child({label: 'HealthCheck'});
65
this.blueskyService = blueskyService;
7-
this.unsplashService = unsplashService;
6+
this.plantnetApiService = plantnetApiService;
87
this.pluginsCommonService = pluginsCommonService;
9-
this.grBirdApiService = grBirdApiService;
108
this.logsService = logsService;
119
try {
12-
this.isAvailable = unsplashService.isReady();
10+
this.isAvailable = plantnetApiService.isReady();
1311
this.logger.info((this.isAvailable ? "available" : "not available"));
1412
} catch (exception) {
1513
this.pluginsCommonService.logError("init", exception);
@@ -34,8 +32,11 @@ export default class HealthCheck {
3432
const {logger, pluginsCommonService} = this;
3533
logger.info(`healthCheck - doSimulate:${doSimulate} - context:${JSON.stringify(context)}`);
3634
let errorCount = 0;
35+
36+
/***************************** Checks *******************************************************/
3737
errorCount = await this.checkLogs(errorCount);
3838
errorCount = await this.checkBlueskySearch(errorCount);
39+
errorCount = await this.checkPlantNetID(config, errorCount);
3940

4041
const sentence = pluginName + (errorCount > 0 ? `❌ done with ${errorCount} errors.` : "✅ done without issue.");
4142
return await pluginsCommonService.resultSimple(pluginName, context, sentence);
@@ -78,12 +79,40 @@ export default class HealthCheck {
7879
return errorCount;
7980
}
8081

82+
async checkPlantNetID(config, errorCount) {
83+
const start = Date.now();
84+
const target = "plantnetApiService.plantnetIdentify";
85+
try {
86+
const {doSimulate, context} = config;
87+
const imageUrl = "https://cdn.bsky.app/img/feed_fullsize/plain/did:plc:bjivtavjwicclemh6xsotprl/bafkreib6aziube7wpdu2c7dhbgdbeofilny2faornvbhj23n6w7g7nzege@jpeg"
88+
const {
89+
result,
90+
plantnetResult = null
91+
} = await this.plantnetApiService.plantnetIdentify({
92+
imageUrl, // candidatePhoto?.fullsize,
93+
"doSimulate": false,
94+
"doSimulateIdentify": doSimulate,
95+
"simulateIdentifyCase": 'GoodScoreImages',
96+
context
97+
});
98+
this.reportSuccess(target, Date.now() - start,
99+
`result : ${JSON.stringify({result, plantnetResult})}`);
100+
} catch (error) {
101+
errorCount++;
102+
this.reportError(target, Date.now() - start, error)
103+
}
104+
return errorCount;
105+
106+
107+
}
108+
81109
reportSuccess(target, durationMs, successMsg) {
82110
this.logger.info(`🧪✅ healthCheck - ${target} (${durationMs} ms) ${successMsg}`);
83111
}
84112

85113
reportError(target, durationMs, error) {
86114
this.logger.info(`🧪❌ healthCheck - ${target} (${durationMs} ms) error: ${error.message}`);
87115
}
116+
88117
}
89118

src/plugins/Plantnet.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ export default class Plantnet {
7575
doSimulate,
7676
doSimulateIdentify,
7777
simulateIdentifyCase,
78-
candidate,
79-
tags,
8078
context
8179
});
8280
step = "handle plantnet identification";

0 commit comments

Comments
 (0)