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

Support Moonraker and therefore Klipper #3168

Open
wants to merge 52 commits into
base: develop
Choose a base branch
from

Conversation

davidzwa
Copy link
Collaborator

@davidzwa davidzwa commented Apr 26, 2024

Implementation

  • Build Moonraker API client
  • Build Moonraker Websocket client
  • Introduce PrinterType + SQLite migration
  • Decouple PrinterFile database from cache: this database will not be used in the next release (kept for backwards compatibility)
  • Adjust LoginDto to carry PrinterType around
  • Build client updates for new Printer Type
  • Introduce Printer API for printer control, file actions and gcode commands
    • Implement basic OctoprintApi
    • Implement basic MoonrakerApi
  • Build PrinterApiFactory for scoped and non-scoped printer api resolution with Awilix (overridable service registration by providing asValue(null) for printerApi dependency)
  • Adjust printerResolveMiddleware to use new printerApi:IPrinterApi scoped dependency
  • Adjust PrinterFilesStore to use PrinterApiFactory for non-scoped PrinterApi
  • Receive, extract and transform specific socket events for MR+OP in such a way that the UI has 1 truth for PrinterStateStore
    • Implement websocket RPC request-response with timeout
    • Socket setup now involves object subscription or event subscription
    • Pick roughly which "objects" and "events" are needed instead of sending everything (print_stats, pause_resume, idle_timeout, heaters, heater_bed)
    • Transform the objects to a standardized format
    • Also transform OctoPrint current to a similar format
    • Plan ahead: pick exactly which "objects" and "events" are needed instead of sending everything
  • Abstract the UI PrinterStateStore so it can handle Moonraker "objects" similar to Octoprint events
  • Fix: add printerType to YAML export
  • Fix: API tests
  • Fix: cant download file
  • Fix: cant delete file
  • Fix: printing file is not presented in sidenav
  • Add a interval to socket which queries server info state as a fallback mechanism for webhooks object
  • Moonraker emergency stop results in paused mode?
    image
  • Rectify any tile state, printer list row state, job menu state, toolbar summary state or sidenav state
  • Fix: Moonraker does not require API Key
  • Move printer current conversion into socket adapter
  • Query webook object to determine operational state
  • Fix: klipper service stoppage should at least result in disconnected state, with connect resulting in klipper restart
  • Fix: klippy non-responsive or 503 error should lead to disconnected or offline
  • Fix axios upload tracker mechanism (or investigate UI bug)
  • Restore the PrinterStateUpdatePollTask to at least report the states, it has no responsibility anymore
  • Speed up reconnect action from UI, its so slow right now
  • When no printer current state is known, weird state is show in UI. Instead "loading" should be presented.

Minimum happy flow tests (acceptance criteria):

  • Showing the file list should work and files should be sorted by upload date (newest at the top)
  • After an update in the file list, the sidenav should show this update after reopening
  • Uploading a file should upload it to Moonraker
  • Uploading a file should lead to printing UI tile state
  • Downloading a file should work
  • Deleting a file in sidenav should lead to file being removed for OctoPrint/Moonraker and list being cleared
  • Start/pause/cancel actions should lead to appropriate tile and sidenav states
  • Printer control should lead to appropriate home/move response (GCode should be comparable to OctoPrint control)
  • Emergency stop should work
  • Reconnecting the socket should lead to a refreshed backend socket connection
  • Disabling the printer should lead to stopped socket, and a disabled print state interval
  • Test printer should show simple and consistent messages (not the technical ones)
    • DNS check
    • Auth check (if enabled)
    • API version check
    • Connection check or MCU+host state check
    • Printer state available check
    • Socket state check
    • Disk/CPU check?

Unhappy flow tests:

  • Batch import should not break on missing printer type
  • Printer import should select what printer type to default to (OctoPrint by default)
  • Disconnecting from the moonraker API should lead to disconnect state/color on tile
  • Restarting the klippy host or power toggling it, should lead to exclamation mark on the tile accordingly
  • Any MCU firmware crash, should lead to exclamation mark on the tile accordingly

Beta release actions:

  • Add release notes
  • General code cleanup
    • Remove PrinterConnectionCache backend store
    • Remove PluginFirmwareUpdateController and push to git branch
    • Cleanup unused backend and frontend DTOs
    • Model OctoPrint client DTOs better
  • Write integration tests to cover file store, printer api's, printer file controller and printer controller
  • UI update pushed + new minor minimum requirement in API
  • Decide about CustomGcodeController dupe sendEmergencyM112 vs PrinterApi command (printer API is better, but backwards compat fallback + deprecation note + github issue is best, just in case)
  • Decide to use Octoprint compatible /api/job and /api/printer APIs or Moonraker object subscriptions/polling
  • Tweak moonraker object subscription, add debug mode which exposes more objects
  • Plan ahead to see if Octoprint subscriptions are comparable to Moonraker object subscription
  • Figure out disconnect/connect difference between Klippy and OctoPrint (or disable the capability for (dis)connect in case of Klipper)

@davidzwa davidzwa added the epic Collection issue or big subproject. label Apr 26, 2024
@davidzwa davidzwa added this to the 1.7 milestone Apr 26, 2024
@davidzwa davidzwa self-assigned this Apr 26, 2024
@davidzwa davidzwa linked an issue Apr 26, 2024 that may be closed by this pull request
18 tasks
@davidzwa davidzwa force-pushed the feat/2797-support-moonraker-and-klippy-api-basics branch 6 times, most recently from edb85df to 6af5ddf Compare May 3, 2024 12:55
@davidzwa davidzwa force-pushed the feat/2797-support-moonraker-and-klippy-api-basics branch 3 times, most recently from 11c227d to 01bb7a5 Compare May 7, 2024 18:30
Copy link

codecov bot commented May 7, 2024

Codecov Report

Attention: Patch coverage is 59.97680% with 345 lines in your changes are missing coverage. Please review.

Project coverage is 68.58%. Comparing base (ab0e941) to head (3debb0f).

Files Patch % Lines
.../services/moonraker/moonraker-websocket.adapter.ts 53.54% 59 Missing ⚠️
src/controllers/printer.controller.ts 58.59% 53 Missing ⚠️
src/services/moonraker.api.ts 28.16% 51 Missing ⚠️
.../services/octoprint/octoprint-websocket.adapter.ts 35.41% 31 Missing ⚠️
src/shared/websocket-rpc-extended.adapter.ts 24.39% 31 Missing ⚠️
src/services/octoprint.api.ts 63.63% 20 Missing ⚠️
src/services/moonraker/moonraker.client.ts 22.22% 14 Missing ⚠️
src/services/octoprint/octoprint.client.ts 73.07% 14 Missing ⚠️
src/migrations/1713897879622-AddPrinterType.ts 60.00% 12 Missing ⚠️
src/controllers/printer-files.controller.ts 85.18% 8 Missing ⚠️
... and 26 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3168      +/-   ##
===========================================
+ Coverage    67.71%   68.58%   +0.86%     
===========================================
  Files          214      224      +10     
  Lines         8664     8880     +216     
  Branches      1055     1155     +100     
===========================================
+ Hits          5867     6090     +223     
+ Misses        2796     2789       -7     
  Partials         1        1              
Flag Coverage Δ
server-nodejs 68.58% <59.97%> (+0.86%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@davidzwa davidzwa force-pushed the feat/2797-support-moonraker-and-klippy-api-basics branch from 5b09c14 to 34ad403 Compare May 9, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Collection issue or big subproject.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Moonraker and Klippy API (basics)
1 participant