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: Connect to DHE worker #134

Merged
merged 89 commits into from
Oct 18, 2024
Merged

feat: Connect to DHE worker #134

merged 89 commits into from
Oct 18, 2024

Conversation

bmingles
Copy link
Collaborator

@bmingles bmingles commented Sep 13, 2024

Initial DHE connection feature:

  • Connect to configured DHE server
  • Prompt for credentials
  • Create / delete core+ workers (currently using default settings)
  • Determine worker type to create based on active editor languageid
  • Auto dispose on vscode restart

Testing

Setup

  • Connect to VPN, and have an available DHE server (dev-sanluis is what I've been using)

    Note It can be helpful to open a Query Monitor on this server to see workers get created / destroyed via the extension in the steps that follow.

  • Configure the DHE server in vscode user or workspace settings:

    {
      "deephaven.enterpriseServers": [
        "https://dev-sanluis.int.illumon.com:8123/"
      ],
    }
  • Pull this branch, npm install packages, then f5 for debugging. It should automatically open another vscode instance. In that instance, open a vscode folder containing .py / .groovy scripts, or create a new one where files can be put (vscode should remember this folder the next time you run the debugger)

  • Click the DH activity bar item. You should see your configured server in the list of "Running" servers:
    image

  • Click on the server to initiate login flow. Provide credentials

  • A worker should be created (should see it loading in the CONNECTIONS panel
    image

  • Create a new python file with a simple script:

    from deephaven import time_table
    
    simple_ticking = time_table("PT2S")
  • Run it using double arrows at top of file.

  • If you don't have any other configured, running server, it should automatically connect to the worker you started. Otherwise, you will be prompted to select your connection
    image

  • To discard the worker, you cal use the trash icon in the connection tree item

    image

Copy link

github-actions bot commented Sep 23, 2024

End-to-end Test Summary

Tests 📝Passed ✅Failed ❌Skipped ⏭️Pending ⏳Other ❓Flaky 🍂Duration ⏱️
660000004:46:22
A ctrf plugin

Detailed Test Results

NameStatusmsFlaky 🍂
should default to the correct settingspassed ✅2040
should return custom settings: Empty configspassed ✅252
should return custom settings: Populated configspassed ✅101
should be able to load VSCodepassed ✅925
should only be visible when a supported file type is active: test.groovypassed ✅2849
should only be visible when a supported file type is active: test.pypassed ✅1041
A ctrf plugin

Failed Test Summary

No failed tests ✨

Flaky Test Summary

No flaky tests detected. ✨

@bmingles bmingles force-pushed the 79-dhe-connect branch 2 times, most recently from 08b8b6b to 0c51803 Compare September 30, 2024 19:14
@bmingles bmingles changed the base branch from main to 147-esbuild September 30, 2024 19:15
Base automatically changed from 147-esbuild to main October 1, 2024 16:41
@bmingles bmingles force-pushed the 79-dhe-connect branch 2 times, most recently from 16f9bef to c953d79 Compare October 1, 2024 22:19
@bmingles bmingles marked this pull request as ready for review October 9, 2024 16:14
@bmingles bmingles requested a review from vbabich October 9, 2024 16:54
src/dh/dhe.ts Outdated
* @param matchSerial Serial to match.
* @returns The matching `QueryInfo` or `undefined` if not found.
*/
export function findQueryConfigForSerial(
Copy link

Choose a reason for hiding this comment

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

I don't know if it matters in your case, but known configs may be not fully populated on login. The client fires configadded for each of the remaining queries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getWorkerInfoFromQuery calls this function in response to EVENT_CONFIG_UPDATED events until it finds a match. Should that work, or does EVENT_CONFIG_ADDED need to be accounted for as well?

Copy link

Choose a reason for hiding this comment

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

Scanning all known configs on each update can be problematic with something like 10k+ queries since the update event is fired multiple times in the query lifecycle.
I think EVENT_CONFIG_ADDED needs to be handled instead of EVENT_CONFIG_UPDATED. Also check if event.details have the info you need so you don't have to re-scan the known configs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIR, I had originally tried that one, but the worker url wasn't available when it was added. It only showed up after a future update. I could be misremembering though.

Copy link

Choose a reason for hiding this comment

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

Right, that seems possible. Was the worker URL eventually available in the update event details?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

src/dh/dhe.ts Outdated
serverConfigValues.timeZone ??
Intl.DateTimeFormat().resolvedOptions().timeZone;

const scheduling = QueryScheduler.makeDefaultScheduling(
Copy link

Choose a reason for hiding this comment

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

It seems possible to create an IC query with an arbitrary scheduling type, though Charles mentioned it should be Temporary scheduling with the InteractiveConsoleTemporaryQueue queue name. See make_temporary_config for more details - https://docs.deephaven.io/pycoreplus/20240517/_modules/deephaven_enterprise/client/controller.html#ControllerClient.make_temporary_config

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@vbabich
Looks like that calls:https://docs.deephaven.io/pycoreplus/20240517/_modules/deephaven_enterprise/client/generate_scheduling.html#GenerateScheduling.generate_temporary_scheduler

Does that mean instead of calling makeDefaultScheduling, we'd want to add a new method like makeTemporaryScheduling and return an array of key=value tokens similar to generate_temporary_scheduler?

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've created a PR based on the referenced code that "should" give us a comparable temporary schedule in the JS client:
https://github.com/deephaven-ent/iris/pull/2348

Copy link

Choose a reason for hiding this comment

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

Yes, makeDefaultScheduling generates the scheduling config for new Script type queries I'd add a function for temporary scheduling.

src/dh/dhe.ts Outdated
// This Promise will respond to config update events and resolve when the worker
// is ready.
const queryInfo = await new Promise<QueryInfo>(resolve => {
dheClient.addEventListener(dhe.Client.EVENT_CONFIG_UPDATED, _event => {
Copy link

Choose a reason for hiding this comment

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

EVENT_CONFIG_UPDATED is fired fairly often and scanning known configs can be problematic on large query sets. I'd do an initial findQueryConfigForSerial and subscribe to the update event if the info object with the URL isn't found.

Copy link

Choose a reason for hiding this comment

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

A couple of notes:

  • addEventListener returns a callback remover. Need to remove the listener on resolve/reject.
  • the Promise gets stuck in Pending if the query is created but ends up in a Failed state. Might need to check if the query status is one of the valid startup statuses.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bmingles bmingles requested a review from vbabich October 17, 2024 22:41
@bmingles bmingles merged commit f9f1c6c into main Oct 18, 2024
3 checks passed
@bmingles bmingles deleted the 79-dhe-connect branch October 18, 2024 17:15
@bmingles bmingles linked an issue Oct 21, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create default interactive console PQ connection
2 participants