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

[CZID-8457] Create a file - part 2 #65

Merged

Conversation

robertaboukhalil
Copy link
Contributor

Adding tests for the changes in #61

@robertaboukhalil robertaboukhalil marked this pull request as ready for review September 22, 2023 17:19
@@ -38,7 +38,7 @@ def download_link(
) -> typing.Optional[SignedURL]:
if not self.path: # type: ignore
return None
key = self.path.lstrip("/") # type: ignore
key = self.path # type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While i'm at it, I'm removing all lstrip calls and making sure the file paths generated in the seed script don't start with /

@@ -11,6 +12,12 @@
Faker.add_provider(EnumProvider)


def generate_relative_file_path(obj) -> str: # type: ignore
fake = faker.Faker()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to use factory.Faker() here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I tried that but I can't find a way to evaluate the object afterwards:

Screenshot 2023-09-22 at 11 21 47 AM

And if I don't evaluate it, it will try to store the object itself in the DB, which fails

mutation = f"""
mutation MyQuery {{
createFile(entityId: "{entity_id}", entityFieldName: "{entity_field}",
fileName: "test.fastq", fileSize: 123, fileFormat: "fastq") {{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have (/want/need?) to get the file size info as part of the 'create' call?

Copy link
Contributor Author

@robertaboukhalil robertaboukhalil Sep 22, 2023

Choose a reason for hiding this comment

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

Not sure actually, I don't think we need the file size to be stored in the DB for the app to work. The only use case I can think of is: we want basic stats about how much certain uploaded files take up on S3 and querying the DB would be much faster than querying S3 (but not guaranteed to be accurate).

assert output["errors"] is not None
return

assert output["data"]["createFile"]["url"] == "https://local-bucket.s3.amazonaws.com/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we return a fully formed signed URL instead of all the parts of one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried putting it all in a URL but it didn't work for some reason, I had to send the fields in the body of the POST request

@robertaboukhalil robertaboukhalil merged commit e87b76e into main Sep 22, 2023
2 checks passed
@robertaboukhalil robertaboukhalil deleted the raboukhalil/CZID-8457-upload-signed-urls-part-2 branch September 22, 2023 21:33
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