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: drop file type restriction for upload #236

Merged
merged 7 commits into from
Feb 11, 2025

Conversation

ArzelaAscoIi
Copy link
Member

@ArzelaAscoIi ArzelaAscoIi commented Feb 10, 2025

This pull request removes the SUPPORTED_TYPE_SUFFIXES constant and updates the codebase to handle file type validation differently. The changes focus on simplifying the file upload process and removing redundant checks.

Removal of SUPPORTED_TYPE_SUFFIXES:

Updates to file upload methods:

Test updates:

Copy link

github-actions bot commented Feb 10, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  deepset_cloud_sdk/_service
  files_service.py
Project Total  

This report was generated by python-coverage-comment-action

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 12 changed files in this pull request and generated no comments.

Files not reviewed (7)
  • deepset_cloud_sdk/_utils/constants.py: Evaluated as low risk
  • deepset_cloud_sdk/_service/files_service.py: Evaluated as low risk
  • deepset_cloud_sdk/workflows/sync_client/files.py: Evaluated as low risk
  • tests/integration/service/test_integration_files_service.py: Evaluated as low risk
  • tests/unit/api/test_files.py: Evaluated as low risk
  • tests/unit/service/test_files_service.py: Evaluated as low risk
  • deepset_cloud_sdk/cli.py: Evaluated as low risk
Comments suppressed due to low confidence (1)

deepset_cloud_sdk/workflows/async_client/files.py:149

  • Ensure that the removal of the file type restriction is covered by tests to avoid unintended behavior.
:param desired_file_types: A list of allowed file types to upload. If not provided, all files are uploaded.
Copy link
Contributor

@wochinge wochinge 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!

@staticmethod
def _preprocess_paths(
paths: List[Path],
spinner: yaspin.Spinner = None,
recursive: bool = False,
desired_file_types: Optional[List[str]] = None,
desired_file_types: List[str] | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: we could use sth like the following so that you can get rid of all the None checks

class AlwaysContains:
    def __contains__(self, item):
        return True

fake_list = AlwaysContains()

print(42 in fake_list)  # True
print("hello" in fake_list)  # True
print(None in fake_list)  # True

Copy link
Contributor

Choose a reason for hiding this comment

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

(it's in my opinion easy to miss the check somewhere)

Copy link
Member Author

Choose a reason for hiding this comment

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

you mean replacing the native List objects with a class ? I would need to adjust it also within the typer Argument => CLI parsing, but might work.

Copy link
Contributor

Choose a reason for hiding this comment

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

More replacing the None with an object behaving like a list (basically simulating the null pattern https://refactoring.guru/introduce-null-object

@ArzelaAscoIi ArzelaAscoIi merged commit cb35d35 into main Feb 11, 2025
9 of 10 checks passed
@ArzelaAscoIi ArzelaAscoIi deleted the feat/dropFileTypeRestriction branch February 11, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants