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

Exports tagging #2969

Merged
merged 21 commits into from Jan 17, 2024
Merged

Exports tagging #2969

merged 21 commits into from Jan 17, 2024

Conversation

OAGr
Copy link
Contributor

@OAGr OAGr commented Jan 15, 2024

This does a few things:

  1. Tags exported variables and top-level exported dicts with exportData data tag.
  2. In addition to "Results" and "Variables", the Playground now has "Imports" and "Exports".
  3. Some refactoring to SqProject.index.
  4. Minor change to VDict valueToString() method. (Adds a space between commas. This required changing several tests).

Closes #2924

Copy link

changeset-bot bot commented Jan 15, 2024

🦋 Changeset detected

Latest commit: 1b8f08c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@quri/squiggle-lang Patch
@quri/squiggle-components Patch
@quri/prettier-plugin-squiggle Patch
@quri/versioned-squiggle-components Patch
vscode-squiggle Patch
@quri/squiggle-textmate-grammar Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
quri-hub ✅ Ready (Inspect) Visit Preview Jan 17, 2024 11:03pm
squiggle-components ✅ Ready (Inspect) Visit Preview Jan 17, 2024 11:03pm
squiggle-website ✅ Ready (Inspect) Visit Preview Jan 17, 2024 11:03pm
1 Ignored Deployment
Name Status Preview Updated (UTC)
quri-ui ⬜️ Ignored (Inspect) Visit Preview Jan 17, 2024 11:03pm

* main:
  Added lint error
  Better documentation examples
  Minor fix to examples ordering
  Fixed Fn examples for FnDocumentation
  Removed interactiveExamples
  Refactoring examples to use custom makeFnExample fn
  Continued small docs improvements
  Small tag doc fixes
  Generic doc cleanup
@@ -225,6 +225,15 @@ example2 = {|x| x + 1}`,
}),
],
}),
maker.make({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We also could just keep this out of the public interface for now, if we want.

@OAGr OAGr marked this pull request as ready for review January 16, 2024 02:45
@OAGr
Copy link
Contributor Author

OAGr commented Jan 17, 2024

(I addressed the main comments above)

Copy link
Collaborator

@berekuk berekuk left a comment

Choose a reason for hiding this comment

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

  • Happy to see "Exports" and "Imports" panels in viewer
  • tbh I'm still not convinced that tagging each export is necessary, but we'll see, can remove it later as we discussed
  • extra stuff showing in "Exports" seems critical, not sure why that happens
  • I'll take a look at versioned-components issues

return [key, _value];
});
const exports = bindings.filter(
(value, key) => value.tags?.exportData !== undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

Somehow this leads to tagged unexported values showing in "Exports":
Screenshot 2024-01-17 at 14 24 01

Copy link
Contributor Author

@OAGr OAGr Jan 17, 2024

Choose a reason for hiding this comment

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

(Fixed! The problem is that it should have been .exportsData(), not .exportData.)

let _value = value;
if (exportNames.has(key)) {
_value = value.mergeTags({
exportData: { sourceId: this.sourceId, path: [key] },
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is more convoluted than I'd like, I see why you had to do it this way, but now I want to move this logic deeper in the reducer, store exports and bindings directly in context.

(I'll do it later)

? internalOutputR.value.externals.explicitImports
: internalOutputR.value[field];
const dict = new SqDict(
field === "exports"
Copy link
Collaborator

Choose a reason for hiding this comment

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

These ternaries are complicated, I'd suggest this:

const bindings = makeTopDict(internalOutputR.value.bindings);
const exports = makeTopDict(internalOutputR.value.exports.mergeTags({ name: sourceId }));
const imports = makeTopDict(internalOutputR.value.externals.explicitImports);

With makeTopDict containing the rest of the common code.

valueAst: astR.value,
valueAstIsPrecise: true,
path: new SqValuePath({
root: "bindings",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this vary for different fields?

packages/squiggle-lang/src/public/SqProject/index.ts Outdated Show resolved Hide resolved
…quiggle into Exports-tagging

* 'Exports-tagging' of github.com:quantified-uncertainty/squiggle:
  fix hub build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Show Imports in new Result/Variables dropdown
2 participants