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

feat(sdk): collection files #46

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

feat(sdk): collection files #46

wants to merge 17 commits into from

Conversation

artem-chupryna
Copy link
Contributor

No description provided.

@artem-chupryna artem-chupryna changed the title Numerous files feat(sdk): collection files Oct 17, 2024
Copy link
Contributor

@jfeodor jfeodor left a comment

Choose a reason for hiding this comment

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

Oops, I forgot to submit the review

python/src/numerous/_client/_fs_client.py Outdated Show resolved Hide resolved
def get_collection_file(
self, collection_id: str, file_key: str
) -> Optional[CollectionFileReference]:
path = self._base_path / collection_id / f"{file_key}.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to ensure that files and documents do not overwrite eachother :)

python/tests/test_collections_files.py Outdated Show resolved Hide resolved
Comment on lines +172 to +175
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.content = ""
mock_get.return_value = mock_response
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider what a S3 download URL for a non-existing item would return (probably 404) 👍

python/tests/test_collections_files.py Outdated Show resolved Hide resolved
Comment on lines +239 to +240


Copy link
Contributor

Choose a reason for hiding this comment

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

Remove extra spaces :)

python/src/numerous/collection/numerous_file.py Outdated Show resolved Hide resolved
python/src/numerous/collection/numerous_file.py Outdated Show resolved Hide resolved
python/src/numerous/collection/numerous_file.py Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Oct 28, 2024

@jfeodor
Copy link
Contributor

jfeodor commented Oct 29, 2024

A general comment: Rename numerous_file.py as just file.py and rename NumerousFile class as just File.

Comment on lines +376 to +377
downloadURL=os.fspath(file.path),
uploadURL=os.fspath(file.path),
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no upload/download in the file system client. This indicates that something about the implementation should fundamentally be changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should change the clients to not return graphql types, but our own types. That way we can do away with things like having a download URL related to a file on the file system.

Copy link
Contributor

Choose a reason for hiding this comment

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

Basically, the clients should return NumerousFile and NumerousCollection objects directly. For files the handling of file content should be done by calls to the client internally.

For example there might just be similar methods in the client. Could be something like:

class NumerousFile:
    ...
    def open(self) -> BufferedReader:
        return self._client.open_file(self.id)

Then FileSystemClient and GraphQLClient could implement Client.open_file in different ways.

Comment on lines +289 to +295
if self.file_id is not None:
tagged_file = self._client.add_collection_file_tag(
self.file_id, TagInput(key=key, value=value)
)
else:
msg = "Cannot tag a non-existent file."
raise ValueError(msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Short circuit this as well, and also in tag_delete.

Comment on lines +164 to +165


Copy link
Contributor

Choose a reason for hiding this comment

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

Clean up extranous empty line

Copy link
Contributor

@jfeodor jfeodor Oct 29, 2024

Choose a reason for hiding this comment

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

Check all docstrings for this issue. It exists in multiple places.

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.

2 participants