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

Cannot use relative files #101

Closed
sareini opened this issue Oct 17, 2022 · 18 comments
Closed

Cannot use relative files #101

sareini opened this issue Oct 17, 2022 · 18 comments

Comments

@sareini
Copy link

sareini commented Oct 17, 2022

In databricks, I use git syncing when developing. Inside a directory, I have a config file my job can read and use to load some runtime variables.

Ex:

db_job = configparser.ConfigParser()
db_job.read('databricks.ini')

When using the extension, this loads nothing and it cannot find the file at the same directory level

@gbrueckl
Copy link
Collaborator

where exactly would that databricks.ini file reside?
inside your workspace (using Files in Repos) or on your DBFS?

if it is on DBFS, this will not work as your notebook is in the workspace and is not aware of the current path on DBFS what might be the case if you execute it as a Python job

if it is on the workspace, it currently also will not work but I could check to see if this is possible

just let me know what your exact scenario is

@sareini
Copy link
Author

sareini commented Oct 17, 2022

Its currently under a repo workspace.

So I have the git repo sync'd w/ databricks. And the structure of the folder is

my_directory/
my_directory/databricks.ini
my_directory/job1
...

where job1 is trying to read from databricks.ini. Something else I noticed is that I cant open that databricks.ini file via the plugin, but can the job1 file. Not sure if that is helpful!

@gbrueckl
Copy link
Collaborator

Non-code files like your .ini uses a different API to up/download then code files, but this feature will be added soon

Regarding your problem: does that same code work if you execute it via the Databricks Web UI?

@sareini
Copy link
Author

sareini commented Oct 18, 2022

Yep, works in the databricks UI! We have that files in repo feature enabled

@gbrueckl
Copy link
Collaborator

What library is that ConfigParser using to read the file?
Some regular python code like os?

@sareini
Copy link
Author

sareini commented Oct 18, 2022

Yep! And some others, fwiw it should come w/ any python and just uses some regular default python packages https://docs.python.org/3/library/configparser.html#module-configparser

Grabbed these from source code

from collections.abc import MutableMapping
from collections import ChainMap as _ChainMap
import functools
import io
import itertools
import os
import re
import sys
import warnings

@gbrueckl
Copy link
Collaborator

I think I found a fix which will be implemented with the next release!

@gbrueckl
Copy link
Collaborator

the issue should be fixed in this release, can you please try it and report back - thanks!
https://github.com/paiqo/Databricks-VSCode/releases/tag/v1.2.0

Note: it is not yet published to the VSCode gallery

@sareini
Copy link
Author

sareini commented Oct 20, 2022

It still isnt working for me. I hover over databricks.ini and it shows [Online Only].

I added

  "databricks.connection.default.exportFormats": {
     ...
    "Ini": ".ini"
  }

but it didnt help

@gbrueckl
Copy link
Collaborator

so the original issue should be fixed - which was executing your code from the first post

to modify the Files in Repo - this is currently only working if you open it via dbws:/ from your VSCode solution explorer
you can simply click the Orange icon in your Workspace Browser to add the dbws:/ to your VSCode solution explorer
image
browsing to your file from there should allow you to open and edit it

@sareini
Copy link
Author

sareini commented Oct 20, 2022

Yes that does work! Thank you so much! The notebook can run and load those files.

I did have to click Add Databricks to VSCode workspace for the code to execute. Without it, it still couldnt find the file.

@gbrueckl
Copy link
Collaborator

it should also work if you run it via the Workspace browser (basically running the local file)
of course, in this case the reference file also has to exist online in the databricks workspace as the code is running there and looking for the file there

can you test this again please as it worked in my tests

@sareini
Copy link
Author

sareini commented Oct 21, 2022

image

I opened the notebook via the workspace tab. I can see the ini file in the same directory, but it still cant read it. Unless I add it to the workspace.

If it could read it, the output would be

['test.ini']

@gbrueckl
Copy link
Collaborator

gbrueckl commented Oct 22, 2022 via email

@sareini
Copy link
Author

sareini commented Oct 22, 2022

I started a databricks cluster and specified that as the kernel

@gbrueckl
Copy link
Collaborator

ok, I think I found the issue
it further seems that DBR 11+ is required for this to work in the end

@gbrueckl
Copy link
Collaborator

just published v1.2.1 to the gallery!
please provide some final feedback

@sareini
Copy link
Author

sareini commented Oct 24, 2022

Downloaded the new version, double checked I have DBR 11+, and everything is working as expected! Thank you so much for the quick turnaround!

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