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

[wip] Add Robot Framework language server #493

Closed
wants to merge 24 commits into from

Conversation

bollwyvl
Copy link
Collaborator

@bollwyvl bollwyvl commented Jan 24, 2021

Binder

References

  • fixes Support/test a Robot Framework language server #332 with robotframework-lsp, which is generally available on pypi and conda-forge
  • also adding
    • jupyterlab_robotmode for robot syntax highlighting
    • robotkernel as it has a number of nice bells and whistles for browser-based testing
      • xeus-robot is also very cool, as it works with the debugger, which we need to start considering
        • but I think we want a separate PR that adds all the xeus stuff in one go, as they are most likely to conflict with each other
          • e.g. xeus-python, xeus-sql, xeus-robot, etc.

Code changes

  • add robotframework-lsp in a number of places (not lint, though!)
    • if we find ourselves wanting to use robot notebooks, we can figure out an nblint plugin or something
  • the robotframework 4.0 release is coming up... there might be some version adventures between releases, have pinned for the time being to avoid surprises.
  • validate that spec that robotframework-lsp ships 🎉 works
    • we're better off upstreaming a PR than claiming support for one with tweaks
  • add editor robot tests
  • add notebook robot tests

User-facing changes

  • Users should see nicer integration with robot files and notebooks
    • will demo on our Binder for looking at/running our tests, which is cute
      • browser screenshots can be made to work
        • might need to add apt.txt (or stuff it, and use a Dockerfile)... binder's getting a bit unwieldy

Backwards-incompatible changes

  • N/A

Chores

  • linted
  • tested
  • documented
  • changelog entry

@bollwyvl
Copy link
Collaborator Author

Ahh, rflsp isn't compatible with python 3.6. Knew this day would come.

@bollwyvl
Copy link
Collaborator Author

Woof... the vendored watchdog is going nuts on my setup... will push so we have something to look at in CI/binder, but something's definitely not right:

lsp: 2021-01-24 15:14:18 UTC pid: 159268 - MainThread - EXCEPTION - robocorp_ls_core.jsonrpc.endpoint
Failed to handle request 0

Traceback (most recent call last):
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/jsonrpc/endpoint.py", line 142, in consume
    self._handle_request(
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/jsonrpc/endpoint.py", line 278, in _handle_request
    handler_result = handler(params)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/jsonrpc/dispatchers.py", line 38, in handler
    return method(**(params or {}))
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/python_ls.py", line 261, in m_initialize
    self.workspace = self._create_workspace(rootUri, workspaceFolders or [])
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/server_api/server.py", line 83, in _create_workspace
    return RobotWorkspace(
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/impl/robot_workspace.py", line 18, in __init__
    Workspace.__init__(self, root_uri, workspace_folders=workspace_folders)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/workspace.py", line 265, in __init__
    self.add_folder(folder)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/impl/robot_workspace.py", line 24, in add_folder
    self.libspec_manager.add_workspace_folder(folder.uri)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/impl/libspec_manager.py", line 544, in add_workspace_folder
    folder_info.start_watch(self._observer, self._file_changes_notifier)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/impl/libspec_manager.py", line 260, in start_watch
    self._watch = observer.notify_on_any_change(
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/watchdog_wrapper.py", line 223, in notify_on_any_change
    self._observer.schedule(
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/observers/api.py", line 301, in schedule
    emitter.start()
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/utils/__init__.py", line 110, in start
    self.on_thread_start()
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/observers/inotify.py", line 121, in on_thread_start
    self._inotify = InotifyBuffer(path, self.watch.is_recursive)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/observers/inotify_buffer.py", line 35, in __init__
    self._inotify = Inotify(path, recursive)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/observers/inotify_c.py", line 201, in __init__
    self._add_dir_watch(path, recursive, event_mask)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/observers/inotify_c.py", line 398, in _add_dir_watch
    self._add_watch(full_path, mask)
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/observers/inotify_c.py", line 412, in _add_watch
    Inotify._raise_error()
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/libs/watchdog_lib/watchdog/observers/inotify_c.py", line 424, in _raise_error
    raise OSError(errno.ENOSPC, "inotify watch limit reached")
OSError: [Errno 28] inotify watch limit reached
lsp: 2021-01-24 15:14:18 UTC pid: 159268 - MainThread - EXCEPTION - robocorp_ls_core.python_ls
Error updating document: {'uri': 'file://~/jupyterlab-lsp/atest/examples/example.robot', 'version': 0} with changes: [{'text': '*** Settings ***\nLibrary           SeleniumLibrary\nLibrary           Builtin\n\n*** Variables ***\n${ABC}            abc\n\n*** Keywords ***\nSpecial Log\n    [Arguments]    ${log}\n    [Documentation]    a special log\n    Log    ${log.upper()}!\n\n*** Test Cases ***\nLog Something\n    Special Log    ${ABC}\n\n'}]

Traceback (most recent call last):
  File "~/envs/default/lib/python3.8/site-packages/robotframework_ls/vendored/robocorp_ls_core/python_ls.py", line 318, in m_text_document__did_change
    self.workspace.update_document(
AttributeError: 'NoneType' object has no attribute 'update_document'
lsp: 2021-01-24 15:14:18 UTC pid: 159268 - MainThread - EXCEPTION - robocorp_ls_core.python_ls
Error updating document: {'uri': 'file://~/jupyterlab-lsp/atest/examples/example.robot', 'version': 1} with changes: [{'text': '*** Settings ***\nLibrary           SeleniumLibrary\nLibrary           Builtin\n\n*** Variables ***\n${ABC}            abc\n\n*** Keywords ***\nSpecial Log\n    [Arguments]    ${log}\n    [Documentation]    a special log\n    Log    ${log.upper()}!\n\n*** Test Cases ***\nLog Something\n    Special Log    ${ABC}\n\n'}]

@bollwyvl
Copy link
Collaborator Author

Looks like some changes were made upstream on rflsp, so maybe this will work now?

Of note, it doesn't support a ton of features that intersect with ours... but it's something.

@bollwyvl
Copy link
Collaborator Author

Nope :(

@bollwyvl
Copy link
Collaborator Author

bollwyvl commented Mar 3, 2021

Worth another shot in a couple hours...
conda-forge/robotframework-lsp-feedstock#14

@bollwyvl
Copy link
Collaborator Author

Working on warming this back up, and getting the new, more-maintained (than rflint) robocop up, which will be nice to have for our code anyway.

@bollwyvl
Copy link
Collaborator Author

Gah, i've made a proper mess of things, here. I think given the increasing complexity of the py36/37 stuff, it's time to look at doing an up-front job (or committing) lockfiles with conda-lock.

Basically, the YML in requirements would look more like:

requirements/
  - _base.yml  # what's needed in _every_ env
  - build.yml
  - lint.yml
  - test.yml
  - test-3.6.yml
  - test-3.7.yml
  - test-3.8.yml
  - test-3.9.yml

And permute across these things to yield:

.github/
  - locks/
    - build-3.9-linux-64.conda.lock
    - lint-3.9-linux-64.conda.lock
    - test-3.6-linux-64.conda.lock
    # ...
    - test-3.9-windows-64.conda.lock

Then all of the jobs would just use their respective lockfile in environment-file.

The advantage to checking them in is we'd save the couple minutes up-front of doing the resolve, and have them around for local review. But the danger then becomes if we get lazy with our locks: we've actually found a number of regressions on upstream things by mostly sticking to the bleeding edge... maybe we'd just have one or two jobs that were canary-like.

@krassowski
Copy link
Member

Should we just add the spec for robotframework-lsp and mark it editor support only or partial support to make it more discoverable? I know that pip install robotframework-lsp just works, but it's not in the docs.

@bollwyvl
Copy link
Collaborator Author

Oy! I should definitely warm this back up. rflsp really supports a lot of lsp features now, and should feel really nice.

If we're dropping py 3.6 in #718 , that will make this easier, so i may well re-start from a clean slate.

@krassowski
Copy link
Member

Closing as superseded by #724. Thank you!

@krassowski krassowski closed this Mar 6, 2022
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.

Support/test a Robot Framework language server
2 participants