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

fix client is None #7097

Merged
merged 3 commits into from
Dec 6, 2023
Merged

fix client is None #7097

merged 3 commits into from
Dec 6, 2023

Conversation

d710055071
Copy link
Contributor

@d710055071 d710055071 commented Dec 1, 2023

Closes #7111

Change Description

`
def get_client():
from lakefs.client import Client
clt = Client(username=username, password=password, host=host)
return clt

clt = get_client()

repo = lakefs.Repository(repository_id="datalab",client=clt)

ref = repo.ref(ref_id="main")

stored_object = ref.object(path="coco/coco128.zip")

fd = stored_object.reader()

filedata = fd.read()
save_obj = open("coco128.zip","wb")
save_obj.write(filedata)
save_obj.close()
`

Background

(dinov2) dongzf@dongzf-LEGION-REN7000P-26AMR:/mnt/sda/code/lakeFS-master$ cd /mnt/sda/code/lakeFS-master ; /usr/bin/env /home/dongzf/miniconda3/envs/dinov2/bin/python /home/dongzf/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 50565 -- /mnt/sda/code/lakeFS-master/clients/python-wrapper/study.py
Traceback (most recent call last):
File "/home/dongzf/miniconda3/envs/dinov2/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/dongzf/miniconda3/envs/dinov2/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/dongzf/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 39, in
cli.main()
File "/home/dongzf/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/dongzf/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "/home/dongzf/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "/home/dongzf/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/home/dongzf/.vscode/extensions/ms-python.python-2023.20.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/mnt/sda/code/lakeFS-master/clients/python-wrapper/study.py", line 28, in
fd = stored_object.reader()
File "/mnt/sda/code/lakeFS-master/clients/python-wrapper/lakefs/object.py", line 564, in reader
return ObjectReader(self, mode=mode, pre_sign=pre_sign, client=self._client)
File "/mnt/sda/code/lakeFS-master/clients/python-wrapper/lakefs/object.py", line 209, in init
super().init(obj, mode, pre_sign, client)
File "/mnt/sda/code/lakeFS-master/clients/python-wrapper/lakefs/object.py", line 75, in init
self._pre_sign = pre_sign if pre_sign is not None else client.storage_config.pre_sign_support
AttributeError: 'NoneType' object has no attribute 'storage_config'

Bug Fix

If this PR is a bug fix, please let us know about:

  1. Problem - The reason for opening the bug
  2. Root cause - Discovered root cause after investigation
  3. Solution - How the bug was fixed

New Feature

If this PR introduces a new feature, describe it here.

Testing Details

How were the changes tested?

Breaking Change?

Does this change break any existing functionality? (API, CLI, Clients)

Additional info

Logs, outputs, screenshots of changes if applicable (CLI / GUI changes)

Contact Details

How can we get in touch with you if we need more info? (ex. email@example.com)

@CLAassistant
Copy link

CLAassistant commented Dec 1, 2023

CLA assistant check
All committers have signed the CLA.

@d710055071 d710055071 marked this pull request as draft December 1, 2023 09:34
@N-o-Z N-o-Z added bug Something isn't working python-wrapper labels Dec 3, 2023
@N-o-Z N-o-Z self-requested a review December 3, 2023 21:05
@N-o-Z N-o-Z marked this pull request as ready for review December 3, 2023 21:06
@N-o-Z
Copy link
Member

N-o-Z commented Dec 3, 2023

@d710055071 Thank you for the contribution and nice catch!
Can you please sign the CLA - in order to contribute to the project

@N-o-Z N-o-Z added the exclude-changelog PR description should not be included in next release changelog label Dec 3, 2023
@d710055071
Copy link
Contributor Author

@d710055071 Thank you for the contribution and nice catch! Can you please sign the CLA - in order to contribute to the project

I have added CLA

@d710055071
Copy link
Contributor Author

This is the first line of code I have contributed to the open source community. Thank you very much

Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @d710055071 looks good.
One lint comment

clients/python-wrapper/lakefs/reference.py Outdated Show resolved Hide resolved
@d710055071 d710055071 requested a review from N-o-Z December 6, 2023 00:54
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@N-o-Z N-o-Z merged commit 8af6b7a into treeverse:master Dec 6, 2023
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contributor exclude-changelog PR description should not be included in next release changelog python-wrapper
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Python Wrapper pass client to Object initialization in reference.object()
3 participants