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

Datascript Explorer #67

Closed
tangjeff0 opened this issue May 15, 2020 · 15 comments
Closed

Datascript Explorer #67

tangjeff0 opened this issue May 15, 2020 · 15 comments
Assignees

Comments

@tangjeff0
Copy link
Collaborator

tangjeff0 commented May 15, 2020

#132 https://athensresearch.github.io/athens/cards.html#!/athens.devcards.db_boxes

#91 https://athensresearch.github.io/athens/cards.html#!/athens.devcards.sci_boxes

Using sci, allow users to query their database in the browser. Datalog is a very powerful language and could one day be as common knowledge as SQL.

@tangjeff0 tangjeff0 changed the title Implement sci to for a datascript exploration tool Implement sci for a datascript exploration tool May 15, 2020
@tangjeff0 tangjeff0 added the d/hard difficulty label May 16, 2020
@ticean
Copy link

ticean commented May 17, 2020

❤️ Is this in progress now? This would be a great feature to keep around in the final version!

The sci.web interface is 💯. Is there a reason that we need sci itself or could we use the datascript client in CLJS for the eval?

@tangjeff0
Copy link
Collaborator Author

tangjeff0 commented May 18, 2020

Good question @ticean. We are interested in sci.web beyond pure datascript because we expect that there may be use cases where users want to import arbitrary npm packages. For instance, if they wanted to use other graph visualization libraries.

*Edit: Another reason is that sci provides a safe sandbox for code execution.

@tangjeff0 tangjeff0 mentioned this issue May 18, 2020
jeroenvandijk pushed a commit that referenced this issue May 26, 2020
* Experiment with sci (#67) and devcards (#6)

* fix style

* move devcards ns
@tangjeff0 tangjeff0 changed the title Implement sci for a datascript exploration tool Datascript Exploration May 27, 2020
@tangjeff0 tangjeff0 changed the title Datascript Exploration Datascript Explorer May 27, 2020
@jelmerderonde
Copy link
Contributor

jelmerderonde commented Jun 2, 2020

I'm working on something, not much code yet, but I do have an idea that might work. Current progress can be seen here: https://jelmerderonde.github.io/athens/cards.html#!/athens.devcards.db_boxes.

The code I have builds on the work done earlier by @tomisme in #91.

General idea:

  • Create a block "type" that evaluates it's contents using sci. Provide bindings for datascript functions like q and pull. Also provide a binding to the datascript connection.
  • Results will be displayed below the block in a simple visual browser, displaying single values, lists and tables.
  • Values that indicate a "next step" like a unique id or a reference (we can identify these using the datascript schema) should be clickable. Clicking them generates a new query and a new set of results that can be displayed in the browser.
  • Keep a history of previous queries/result-sets so users can navigate backwards.

Executing queries

  • Provide correct bindings to sci
  • Execute query and display results as plain text
  • Catch errors and display them

Browser

  • Scalar values
  • Sequences --> list
  • Sequences of maps --> table with headers

Navigation

  • Detect "navigatable" datoms
  • Generate queries
  • History with previous queries

Feedback to this idea is appreciated.

@jelmerderonde jelmerderonde self-assigned this Jun 3, 2020
@tangjeff0
Copy link
Collaborator Author

@jelmerderonde great start!


Values that indicate a "next step" like a unique id or a reference ... should be clickable

Love this idea!


Keep a history of previous queries/result-sets so users can navigate backwards.

Keep in mind that we get history and time travel for free with DevCards:

It would be nice to have this a developer tool outside of DevCards too. You get this with Elm, Redux DevTools, and re-frame-10x, but posh/re-posh doesn't have this unfortunately.


If you haven't already, try doing datascript queries in Roam. Things to note about Roam's queries:

  • they eagerly evaluate, which is sometimes annoying
  • if the query is too large, you get an error message. How should we handle large queries?

@jelmerderonde
Copy link
Contributor

@tangjeff0 thanks!


Keep in mind that we get history and time travel for free with DevCards:

Good point, I will enable this next time I work on it.


they eagerly evaluate, which is sometimes annoying

I will have to figure out how to do this, I will also take a look at Roam queries.

@jelmerderonde
Copy link
Contributor

Small update, I've managed to get some minimal browsing going. You can now click on cells that we know contains a :db/id and it will generate some new code for you.

Also, the code is a mess and in need of some cleaning up, I will do that later.

@jelmerderonde
Copy link
Contributor

Another update, see the latest state at: https://jelmerderonde.github.io/athens/cards.html#!/athens.devcards.db_boxes

  • Improved the table React no longer complains about missing :keys
  • If the result is not a map, only the first 10 results are displayed initially. This improves responsiveness.
  • Navigation is also possible on refs and unique attributes.
  • Added an explanation and a button to reset to the initial state.
  • Devcards history is now enabled, allowing you to go back to earlier queries and results.

I think I'm now at a stage where it would be helpful to have some discussion about which direction we should take this in. When is it "good enough" for developers? What questions should they be able to answer with it? How can it be further improved?

I'm looking forward to hearing more ideas and opinions!

@tomisme
Copy link
Contributor

tomisme commented Jun 5, 2020

@jelmerderonde I'm definitely finding it useful for exploring our attributes. I added this to my devcards css:

.com-rigsomelight-devcards_rendered-card {
  display: flex;
  flex-direction: column-reverse;
}

I'm sure it breaks other cards somewhere but it moves the history control bar up above the text box.

@tomisme
Copy link
Contributor

tomisme commented Jun 6, 2020

Some ideas for where we could go:

@tangjeff0
Copy link
Collaborator Author

tangjeff0 commented Jun 6, 2020

I'm sure it breaks other cards somewhere but it moves the history control bar up above the text box.

@tomisme we can override CSS on each individual Devcard namespace. No worries!


Agree with datafy and nav. Let's get inspired by REBL and Datomic On-Prem Console for what other interactions and UI we could build!


Can't wait to have #31 so people can begin querying their own DBs to learn datascript!!

@jelmerderonde
Copy link
Contributor

jelmerderonde commented Jun 9, 2020

I've added some minor improvements in #138:

  • Reverse flex direction of browse db card as suggested by @tomisme
  • Adds the ability to browse "up" the graph, also a suggestion by @tomisme

For now I think this is as far as we should go with this. It should be suitable for experimenting with datascript and exploring the database. When we have a firmer idea on how we will work with datascript and how we want to implement similar functionality in Athens we can pick this up again.

Do you agree @tangjeff0 ?

@tangjeff0
Copy link
Collaborator Author

Looks great @jelmerderonde , approved and merged.

Eventually, when parser is further along, we can implement exploration for [[links]]s and ((block))s.

@jelmerderonde
Copy link
Contributor

Eventually, when parser is further along, we can implement exploration for [[links]]s and ((block))s.

This shouldn't be hard to implement (I think). Let's revisit it when @roryokane deems it ready :-).

@tangjeff0
Copy link
Collaborator Author

Moving this to the "Done" column because doesn't require any immediate action

@tangjeff0
Copy link
Collaborator Author

This has mainly been superseded by #139. Closing!

korlaism pushed a commit to korlaism/athens that referenced this issue Jul 19, 2021
* Experiment with sci (athensresearch#67) and devcards (athensresearch#6)

* fix style

* move devcards ns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants