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

Adapted tokens to be external, CI now builds and installs the package, and unit tests are now using the installed package. #7

Merged
merged 8 commits into from
Sep 6, 2024

Conversation

rawe0
Copy link
Collaborator

@rawe0 rawe0 commented Aug 29, 2024

The tokens are now handled externally to allow parallelism (makes the package stateless) which allows to user to reuse the connection in multiple threads. Methods for handling token operations (check_token, get_token) are still available and public to the user.

The CI has also been updated to build the package and install it using pip and the package structure has been corrected because of this. The unit tests now use the package that is installed instead of importing directly from the .py files, changes in the source code has also been made to reflect this change. This change is important because it tests that the package works as it should as a package.

The lock functionality has also been added.

@rawe0 rawe0 requested review from diocas and glpatcern August 29, 2024 10:06
examples/file_api_example.py Fixed Show fixed Hide fixed
examples/file_api_example.py Fixed Show fixed Hide fixed
examples/auth_example.py Outdated Show resolved Hide resolved
Copy link
Contributor

@diocas diocas left a comment

Choose a reason for hiding this comment

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

The most important comment I have is to please be sure to carve the Auth of the client object. As we discussed, Auth should be handled outside, this means it should not be used anywhere inside.

cs3client/app.py Outdated Show resolved Hide resolved
cs3client/auth.py Outdated Show resolved Hide resolved
cs3client/auth.py Outdated Show resolved Hide resolved
cs3client/cs3client.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
setup.py Show resolved Hide resolved
examples/auth_example.py Outdated Show resolved Hide resolved
examples/app_api_example.py Dismissed Show dismissed Hide dismissed
examples/auth_example.py Dismissed Show dismissed Hide dismissed
examples/checkpoints_api_example.py Dismissed Show dismissed Hide dismissed
examples/file_api_example.py Dismissed Show dismissed Hide dismissed
examples/shares_api_example.py Dismissed Show dismissed Hide dismissed
examples/user_api_example.py Dismissed Show dismissed Hide dismissed
cs3client/file.py Fixed Show fixed Hide fixed
cs3client/file.py Fixed Show fixed Hide fixed
cs3client/file.py Fixed Show fixed Hide fixed
examples/file_api_example.py Fixed Show fixed Hide fixed
examples/lock_example.py Dismissed Show dismissed Hide dismissed
examples/lock_example.py Dismissed Show dismissed Hide dismissed
README.md Outdated Show resolved Hide resolved
.gitignore Show resolved Hide resolved
tests/fixtures.py Show resolved Hide resolved
tests/fixtures.py Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
cs3client/file.py Outdated Show resolved Hide resolved
cs3client/file.py Show resolved Hide resolved
# if the storage does not support locks, set the lock using xattr
if res.status.code == cs3code.CODE_UNIMPLEMENTED and self._config.lock_by_setting_attr:
self._config.lock_not_impl = True
self.set_lock(auth_token, resource, app_name, lock_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point you can directly call _set_lock_using_xattr

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that you changed it in this particular line. But when you have the same logic in different places, the idea is that you do the same for all of them :)

cs3client/file.py Show resolved Hide resolved
cs3client/file.py Show resolved Hide resolved
examples/file_api_example.py Dismissed Show dismissed Hide dismissed
examples/file_api_example.py Dismissed Show dismissed Hide dismissed
self._log.debug(f'msg="Using xattrs to execute RefreshLock" {resource.get_file_ref_str()}" value="{lock_id}"')
try:
currvalue = self.stat(auth_token, resource).arbitrary_metadata.metadata[LOCK_ATTR_KEY]
if currvalue.split("!")[0] == app_name \
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the split only once

@diocas diocas merged commit 4e539b2 into main Sep 6, 2024
3 checks passed
@diocas diocas deleted the dev branch September 6, 2024 14:57
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.

3 participants