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

[BUG] setting databricks.python.envFile is unknown #1462

Closed
copdips opened this issue Nov 20, 2024 · 5 comments
Closed

[BUG] setting databricks.python.envFile is unknown #1462

copdips opened this issue Nov 20, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@copdips
Copy link

copdips commented Nov 20, 2024

Describe the bug

I'm trying to use local .env file with the setting databricks.python.envFile as per extension doc described here. But in VSCode there's no such settings, and by manually adding the setting in the file settings.json, VSCode warns that the setting is unknown.

Screenshots
image

image

System information:

vscode and databricks extension both are latest

@copdips copdips added the bug Something isn't working label Nov 20, 2024
@ilia-db
Copy link
Contributor

ilia-db commented Nov 21, 2024

Hi, our docs are outdated there - we no longer expose the databricks.python.envFile setting. But you can set the python.envFile to your desired path (we read it too and update our internal env var representation, which we use for "Run with DBConnect" commands or for type: 'databricks' launch configs).

Does it cover your use case?

@copdips
Copy link
Author

copdips commented Nov 21, 2024

Thanks for the prompt reply.
Could you please give a example on how to get the env var in the code ?

for example, under the root of my repo there's a file .env with content:

AA=11

the .env file is specified by the python.envFile VSCode setting.

When I run type: 'databricks' launch configs, from the debug console, os.getenv('AA') returns None.

@ilia-db
Copy link
Contributor

ilia-db commented Nov 22, 2024

Sorry for the confusion, type: "databricks" executes the file remotely, and we indeed don't read env file in this case. We do pass over env vars from the env section of the launch config:

Screenshot 2024-11-22 at 11 36 10

For local runs (Run/Debug with Databricks Connect commands) we load the vars from python.envFile.
Screenshot 2024-11-22 at 11 38 13

You can also "extend" local python launch configuration by adding "databricks: true" to it, which will ensure we execute the local files with our bootstrap logic and load the env vars (but our internal DATABRICKS_* vars to make sure dbconnect can access remote workspace, plus the things from python.envFile)

Screenshot 2024-11-22 at 11 47 28

(side note, "python" launch type is now deprecated, but we don't yet support "databricks: true" field on debugpy config)

@copdips
Copy link
Author

copdips commented Nov 22, 2024

Thanks a lot, this is working now !

Regarding the local Python launch, I tested both "type": "python" and "type": "debugpy", and they both work, althought there's a warning for each:

image

@ilia-db
Copy link
Contributor

ilia-db commented Nov 25, 2024

Should be fixed after we merge and release this: #1465

@copdips copdips closed this as completed Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants