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

Enable autocompletion on Python language servers #7068

Open
BlueskyFR opened this issue Jun 6, 2023 · 3 comments
Open

Enable autocompletion on Python language servers #7068

BlueskyFR opened this issue Jun 6, 2023 · 3 comments

Comments

@BlueskyFR
Copy link
Contributor

BlueskyFR commented Jun 6, 2023

Hi!

It seems that the Determined Python package is not compatible with Python language servers because of the way it exports classes/members in __init__.py files.

Issue in VSCode (PyLance/PyRight language server)

image

Fix example

Example fix proposed for this file:

TFKerasExperimentalContext,
TFKerasTrainConfig,
TFKerasTrialContext,
)
from determined.keras._tf_keras_multi_gpu import (
_check_if_aggregation_frequency_will_work,
)
from determined.keras._tf_keras_trial import TFKerasTrial, TFKerasTrialController

from determined.keras import callbacks
from determined.keras._data import (
    _ArrayLikeAdapter,
    _adapt_data_from_data_loader,
    _adapt_data_from_fit_args,
-   ArrayLike,
-   SequenceAdapter,
-   InputData,
+   ArrayLike as ArrayLike,
+   SequenceAdapter as SequenceAdapter,
+   InputData as InputData,
)
from determined.keras._enqueuer import _Enqueuer, _Sampler, _build_enqueuer
from determined.keras._tensorboard_callback import TFKerasTensorBoard
from determined.keras._tf_keras_context import (
-   TFKerasExperimentalContext,
-   TFKerasTrainConfig,
-   TFKerasTrialContext,
+   TFKerasExperimentalContext as TFKerasExperimentalContext,
+   TFKerasTrainConfig as TFKerasTrainConfig,
+   TFKerasTrialContext as TFKerasTrialContext,
)
from determined.keras._tf_keras_multi_gpu import (
    _check_if_aggregation_frequency_will_work,
)
-from determined.keras._tf_keras_trial import TFKerasTrial, TFKerasTrialController
-from determined.keras._load import load_model_from_checkpoint_path
+from determined.keras._tf_keras_trial import (
+   TFKerasTrial as TFKerasTrial,
+   TFKerasTrialController as TFKerasTrialController,
+)
+from determined.keras._load import (
+   load_model_from_checkpoint_path as load_model_from_checkpoint_path,
+)

Result after fix

Not more error

Please note that this should be applied to the entire repo as it does not only concern this file.

@rb-determined-ai
Copy link
Member

Interesting... do you know, does an __all__ = ["TFKerasTrial"] mechanism also meet this need?

@rb-determined-ai
Copy link
Member

rb-determined-ai commented Jun 6, 2023

Also, I am not able to reproduce the error you are seeing either by running pyright directly on a main.py like yours, or by installing the python plugin to vscode and opening such a file.

In vscode I can go-to-def so it seems to understand what determined files to look at, but I don't see any warnings or errors.

Is there a setting or something I'm missing? Can you run pyright directly and get the same error message?

@BlueskyFR
Copy link
Contributor Author

BlueskyFR commented Jun 7, 2023

Hey @rb-determined-ai!
I use the Pylance language server version 2023.5.50 through the Python VSCode extension (version v2023.8.0).

  • First, yes, using __all__ seems to have the same behavior as adding "X as X"
  • Second, for me too go to definition works but the autocompletion is still not working:
    image

I checked Pylance's logs but they did not provide any relevant information

Also I am running the latest pip install determined + Python 3.11 but the behavior is the same using Python 3.10.9

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

No branches or pull requests

2 participants