Repository navigation
feat: Update ChainedConverter to create dynamic paths - #697
Conversation
rubensworks
left a comment
There was a problem hiding this comment.
You could probably go very far with optimizing this one, but it's probably better to wait with that until actual performance issues are encountered. With the relatively small number of media types we have atm, this impl should be fast enough.
I agree, that's why I added a bunch of suggestions should we ever reach that point (which I think we'll never will tbh). |
|
I'd definitely want to test with https://github.com/RubenVerborgh/solid-hue/blob/main/config/config-hue.json#L68-L91, when the current limitations became apparent to me. |
|
It's not urgent to merge so I'll hold of until you could have a look at it. In that config the entire |
If I do that, there seems to be a problem with But equally with just I also tried this, but to no avail: To test if you don't have a Hue Bridge, just diff --git i/src/PhilipsHueStore.ts w/src/PhilipsHueStore.ts
index 6ccc0e2..ba7fd8a 100644
--- i/src/PhilipsHueStore.ts
+++ w/src/PhilipsHueStore.ts
@@ -48,10 +48,7 @@ export class PhilipsHueStore extends BaseResourceStore {
const url = templates.lights.expand(this.settings);
this.logger.debug(`Retrieving light status from ${url}`);
- const response = await this.fetcher.fetch(url);
- assert.equal(response.status, 200);
-
- return new BasicRepresentation(await response.text(), identifier, HueContentType);
+ return new BasicRepresentation('{}', identifier, HueContentType);
}
/** |
RubenVerborgh
left a comment
There was a problem hiding this comment.
Does not work yet with solid-hue.
|
Don't have time yet to look into this, but I do wonder how that error gets thrown since the only time that specific string gets thrown is when doing a But on the other hand, if the old Probably overlooking something. |
I got something wrong, apparently. Sorry for the confusion; better report below. Configuration A {
"@id": "solid-hue:RepresentationConverter",
"@type": "ChainedConverter",
"ChainedConverter:_converters": [
{ "@type": "HueToQuadConverter" },
{ "@type": "QuadToHueConverter" },
]
}(Note that the trailing comma makes this invalid JSON, but it still works. @rubensworks?)
Configuration B {
"@id": "solid-hue:RepresentationConverter",
"@type": "ChainedConverter",
"ChainedConverter:_converters": [
{ "@type": "HueToQuadConverter" },
{ "@type": "QuadToHueConverter" },
{ "@type": "RdfToQuadConverter" }
]
}
|
Yeah, I also noticed that before. Apparently the |
|
What is being PUT in configuration A @RubenVerborgh ? Because the error is correct, it can't convert from turtle to hue+json with that configuration since it only has the hue converters there, not the rdf ones. |
|
@joachimvh The I think the solution is acceptable indeed, however:
|
That's the interesting part then actually, because that should not work. I'm wondering what converter is doing that then. Might have something to do with the other convertingstore it passes through then (from the default config), but I can't immediately say why it works. |
That's my guess. But still weird it doesn't work the other way. The logs with config A for The logs with config A for none (!) The logs with config B for I wonder if the asymmetry has to do with the |
|
The inType only says that that converter needs to convert to the hue format. It could do that if it got quads, but it gets turtle instead which it doesn't know how to handle. That all is as expected. Just realized why it works when doing a GET. It's because you don't have an |
Interesting. So probably the safest config is although that is a tad repetitive if there will be more things that generate quads. But good enough. I'll just finish up my review and then this is good to go, thanks. |
| it('does not throw on async crash.', async(): Promise<void> => { | ||
| jest.useFakeTimers(); | ||
| const result = await converter.handleSafe({ identifier, representation: rep, preferences: {}}); | ||
| const result = await converter.handleSafe({ identifier, representation: rep, preferences: { type: { 'x/x': 1 }}}); |
There was a problem hiding this comment.
I'm a bit worried that the integration test had to change. Seems like the original should still work.
There was a problem hiding this comment.
This might actually be related to the issue I described of matching internal/quads to */* because I think it's the same function that handles that.
There was a problem hiding this comment.
Going through this now, it actually still has to change since we were testing a chain of 2 converters here. With the new ChainedConverter it would be too smart and do the conversion with a path of length 1.
|
It's also a bit special since there are 2 converters in the store chain here. I would actually say this uncovered a bug in the new |
afbc981 to
d659dcc
Compare
Closes #484, see discussion there as well.
Instead of creating a new class I updated
ChainedConvertersince we would have no need for that one anymore after this.The
canHandlecall of this one is going to be more expensive than most other classes, but this should always be the last handler that gets checked so this should be fine.There are some parts that could be move to separate files: the cache could be a separate class file, some functions could be moved to
ConversionUtil, but they are very specific to this implementation so it made sense to me to keep them there.