Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): publish traversed spec to gosling api #978

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/compiler/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ export function compile(
trackInfos = getRelativeTrackInfo(specCopy, theme).trackInfos;
}

// publish the fixed spec
// used for alt-gosling
try {
if (PubSub) {
PubSub.publish('specTraversed', {
Copy link
Member

@sehilyi sehilyi Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the name of the event, how about specProcessed instead? I think users might not understand what the traverse means. And, we can explain what is the different between the input spec and the processed spec briefly in the documentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good idea! I indeed was fidgetting around with a good name, specProcessed is more intuitive

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, bikeshedding, maybe specResolved?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like specResolved, which I think gives a better impression that the spec is not converted into another format, but rather the spec is slightly modified to resolve things!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't resolved give the idea that the spec is fully changed into the 'final form' that it gets for gosling? Because that isn't the case here, it is just partially processed. I'm not sure what the convention is, but I'm afraid resolved gives off the wrong idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How has the input been modified at this point in the program?

The input spec is modified to have default values filled in, and some of the users' incorrectly-specified properties are fixed. Some parts of the spec are not touched by the program (e.g., when values are already specified by users, so no need to add default values), which I think is what @thomcsmits was referring to by "it is just partially processed".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, we don't emit a fully processed spec ("fully processed" as in the final state that it becomes in Gosling), but that might happen in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have truely strong opinions on this, so I'm happy to switch it to specResolved still

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#985 (as this PR is already merged)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have a strong opinion about "resolved" vs "processed", but think this could be a good exercise to be explicit about the state of the gosling spec when it is emitted. "Resolved" and "processed" convey that completion of some transformations/resolution, which is not the case. I have left a longer comment in #985

id: specCopy.id,
data: specCopy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more intuitive and consistent with how we use "data" and "spec" in other API functions

Suggested change
data: specCopy
spec: specCopy

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, I had already written this piece before the standardization! Thanks!

});
}
} catch (e) {
//
}

// Make HiGlass models for individual tracks
createHiGlassModels(specCopy, trackInfos, callback, theme, urlToFetchOptions);
}