Skip to content

Commit 45edfcb

Browse files
committed
Bug 1996291 - Rework getStatus to getStatusByEngineId and fix status reporting in about:inference r=firefox-ai-ml-reviewers,tarek
When going through the tests I could not figure out what this code did. After some sleuthing I realized that it was gathering information for the about:inference. However, the code was badly broken, and incorrect in what it was doing. I simplified the implementation a bit, and fixed the breakage in about:inference. There are no tests for this behavior in about:inference, and there as far as I can tell there are no live models in about:inference that could be used to test this behavior. Since it's a developer-only facing feature, I'm not planning on adding a test for it. Also please note that I'm adding an ml.d.ts file here to centralize some shared types. See the in-flight TypeScript documentation here: https://phabricator.services.mozilla.com/D268571 Differential Revision: https://phabricator.services.mozilla.com/D269982 UltraBlame original commit: 90470f1361431a99abb4526828c12b7adc2296cb
1 parent afd5e83 commit 45edfcb

File tree

7 files changed

+899
-269
lines changed

7 files changed

+899
-269
lines changed

toolkit/components/aboutinference/content/aboutInference.js

Lines changed: 137 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,53 @@ strict
111111
*
112112
*
113113
*
114+
import
115+
{
116+
MLEngineParent
117+
}
118+
from
119+
"
120+
resource
121+
:
122+
/
123+
/
124+
gre
125+
/
126+
actors
127+
/
128+
MLEngineParent
129+
.
130+
sys
131+
.
132+
mjs
133+
"
134+
*
135+
import
136+
{
137+
StatusByEngineId
138+
}
139+
from
140+
"
141+
.
142+
.
143+
/
144+
.
145+
.
146+
/
147+
ml
148+
/
149+
ml
150+
.
151+
d
152+
.
153+
ts
154+
"
155+
*
156+
/
157+
/
158+
*
159+
*
160+
*
114161
Imports
115162
necessary
116163
modules
@@ -557,6 +604,17 @@ i
557604
)
558605
;
559606
}
607+
/
608+
*
609+
*
610+
type
611+
{
612+
MLEngineParent
613+
|
614+
null
615+
}
616+
*
617+
/
560618
let
561619
engineParent
562620
=
@@ -4209,17 +4267,44 @@ updateStatus
42094267
(
42104268
)
42114269
{
4270+
const
4271+
engineParent
4272+
=
4273+
await
4274+
getEngineParent
4275+
(
4276+
)
4277+
;
42124278
if
42134279
(
42144280
!
42154281
engineParent
42164282
)
42174283
{
4284+
/
4285+
/
4286+
The
4287+
engine
4288+
parent
4289+
is
4290+
not
4291+
available
4292+
.
42184293
return
42194294
;
42204295
}
4296+
/
4297+
*
4298+
*
4299+
*
4300+
type
4301+
{
4302+
StatusByEngineId
4303+
}
4304+
*
4305+
/
42214306
let
4222-
info
4307+
statusByEngineId
42234308
;
42244309
/
42254310
/
@@ -4230,38 +4315,37 @@ status
42304315
info
42314316
try
42324317
{
4233-
info
4318+
statusByEngineId
42344319
=
42354320
await
42364321
engineParent
42374322
.
4238-
getStatus
4323+
getStatusByEngineId
42394324
(
42404325
)
42414326
;
42424327
}
42434328
catch
42444329
(
4245-
e
4330+
error
42464331
)
42474332
{
4248-
engineParent
4249-
=
4250-
null
4251-
;
4252-
/
4253-
/
4254-
let
4255-
'
4256-
s
4257-
re
4258-
-
4259-
create
4260-
it
4261-
on
4262-
errors
4333+
console
42634334
.
4264-
info
4335+
error
4336+
(
4337+
"
4338+
Failed
4339+
to
4340+
get
4341+
the
4342+
engine
4343+
status
4344+
"
4345+
error
4346+
)
4347+
;
4348+
statusByEngineId
42654349
=
42664350
new
42674351
Map
@@ -4304,7 +4388,7 @@ is
43044388
empty
43054389
if
43064390
(
4307-
info
4391+
statusByEngineId
43084392
.
43094393
size
43104394
=
@@ -4556,10 +4640,13 @@ for
45564640
let
45574641
[
45584642
engineId
4559-
engineInfo
4643+
{
4644+
status
4645+
options
4646+
}
45604647
]
45614648
of
4562-
info
4649+
statusByEngineId
45634650
.
45644651
entries
45654652
(
@@ -4629,8 +4716,6 @@ statusCell
46294716
.
46304717
textContent
46314718
=
4632-
engineInfo
4633-
.
46344719
status
46354720
;
46364721
row
@@ -4656,8 +4741,6 @@ modelIdCell
46564741
.
46574742
textContent
46584743
=
4659-
engineInfo
4660-
.
46614744
options
46624745
?
46634746
.
@@ -4693,8 +4776,6 @@ dtypeCell
46934776
.
46944777
textContent
46954778
=
4696-
engineInfo
4697-
.
46984779
options
46994780
?
47004781
.
@@ -4730,8 +4811,6 @@ deviceCell
47304811
.
47314812
textContent
47324813
=
4733-
engineInfo
4734-
.
47354814
options
47364815
?
47374816
.
@@ -4767,8 +4846,6 @@ timeoutCell
47674846
.
47684847
textContent
47694848
=
4770-
engineInfo
4771-
.
47724849
options
47734850
?
47744851
.
@@ -8427,6 +8504,21 @@ true
84278504
)
84288505
;
84298506
}
8507+
/
8508+
*
8509+
*
8510+
*
8511+
returns
8512+
{
8513+
Promise
8514+
<
8515+
MLEngineParent
8516+
|
8517+
null
8518+
>
8519+
}
8520+
*
8521+
/
84308522
async
84318523
function
84328524
getEngineParent
@@ -8439,6 +8531,8 @@ if
84398531
engineParent
84408532
)
84418533
{
8534+
try
8535+
{
84428536
engineParent
84438537
=
84448538
await
@@ -8449,6 +8543,16 @@ getMLEngineParent
84498543
)
84508544
;
84518545
}
8546+
catch
8547+
(
8548+
error
8549+
)
8550+
{
8551+
return
8552+
null
8553+
;
8554+
}
8555+
}
84528556
return
84538557
engineParent
84548558
;

toolkit/components/aboutinference/tests/browser/browser.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ head
1212
js
1313
"
1414
]
15+
prefs
16+
=
17+
[
18+
"
19+
browser
20+
.
21+
ml
22+
.
23+
logLevel
24+
=
25+
Debug
26+
"
27+
]
1528
[
1629
"
1730
browser_aboutinference

0 commit comments

Comments
 (0)