Skip to content

Commit

Permalink
refactor: removed not needed file metadata query
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil committed Jul 15, 2024
1 parent 2bb6cac commit 4d51db1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 49 deletions.
19 changes: 4 additions & 15 deletions hexa/datasets/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -424,19 +424,10 @@ type PinDatasetResult {
errors: [PinDatasetError!]!
}

input CreateDatasetFileMetadataInput {
fileId: String!
}

type DatasetFileMetadata {
content: JSON!
dataset_version_file: DatasetVersionFile
}

type CreateDatasetFileMetadataResult {
dataset_file_metadata : DatasetFileMetadata
success: Boolean!
errors: [PrepareVersionFileDownloadError!]!
content: JSON
status: String!
datasetVersionFile: DatasetVersionFile
}


Expand All @@ -446,7 +437,7 @@ extend type Query {
"Get a dataset by its slug."
datasetVersion(id: ID!): DatasetVersion
"Get a dataset file snapshot by fileSnapshot id or by fileId"
datasetFileMetadata(id: ID, fileId: ID): DatasetFileMetadata
datasetFileSnapshot(id: ID, fileId: ID): DatasetFileMetadata
"Get a dataset link by its id."
datasetLink(id: ID!): DatasetLink
"Get a dataset link by its slug."
Expand All @@ -471,8 +462,6 @@ extend type Mutation {
generateDatasetUploadUrl(input: GenerateDatasetUploadUrlInput!): GenerateDatasetUploadUrlResult! @loginRequired
"Create a new file in a dataset version."
createDatasetVersionFile(input: CreateDatasetVersionFileInput!): CreateDatasetVersionFileResult! @loginRequired
"Create dataset version snapshot."
createDatasetVersionFileMetadata(input: CreateDatasetFileMetadataInput!): CreateDatasetFileMetadataResult! @loginRequired
"Prepare to download a file in a dataset version."
prepareVersionFileDownload(input: PrepareVersionFileDownloadInput!): PrepareVersionFileDownloadResult! @loginRequired
"Link a dataset with a workspace."
Expand Down
Empty file.
14 changes: 0 additions & 14 deletions hexa/datasets/schema/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,6 @@ def resolve_create_version_file(_, info, **kwargs):
return {"success": False, "errors": ["PERMISSION_DENIED"]}


@mutations.field("createDatasetVersionFileMetadata")
def resolve_create_version_file_metadata(_, info, **kwargs):
mutation_input = kwargs["input"]

dataset_file_metadata_queue.enqueue(
{
"generate_file_metadata",
{
"file_id": mutation_input["file_id"],
},
}
)


@mutations.field("prepareVersionFileDownload")
def resolve_version_file_download(_, info, **kwargs):
request = info.context["request"]
Expand Down
2 changes: 1 addition & 1 deletion hexa/datasets/schema/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def resolve_dataset_version(_, info, **kwargs):
return None


@datasets_queries.field("datasetFileMetadata")
@datasets_queries.field("datasetFileSnapshot")
def resolve_dataset_file_snapshot(_, info, **kwargs):
try:
if kwargs.get("file_id"):
Expand Down
10 changes: 8 additions & 2 deletions hexa/files/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
from google.oauth2 import service_account
from google.protobuf import duration_pb2

from .basefs import BaseClient, NotFound, ObjectsPage, load_bucket_sample_data_with
from .basefs import (
BaseClient,
BucketObjectAlreadyExists,
NotFound,
ObjectsPage,
load_bucket_sample_data_with,
)


def get_credentials():
Expand Down Expand Up @@ -198,7 +204,7 @@ def generate_upload_url(
client = get_storage_client()
gcs_bucket = client.get_bucket(bucket_name)
if raise_if_exists and gcs_bucket.get_blob(target_key) is not None:
raise ValidationError(f"GCS: Object {target_key} already exists!")
raise BucketObjectAlreadyExists(target_key)
blob = gcs_bucket.blob(target_key)
return blob.generate_signed_url(
expiration=3600, version="v4", method="PUT", content_type=content_type
Expand Down
17 changes: 0 additions & 17 deletions hexa/files/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,20 +532,3 @@ def get_type(self):
class APIGcpTestCase(APITestCase, OnlyGCP, TestCase):
def get_type(self):
return "gcp"


class TestDownloadFromCloudStorage(TestCase):
def test_get_from_gcp(self):
pass
# lines = get_storage("gcp").read_object_lines(
# "hexa-test-datasets",
# "3237e8c2-896d-4628-9054-59d69c785a11/add8469f-14d6-4081-8e02-adb53016f7bd/people.csv",
# 1,
# )
# print(f"Lines are : {lines}")
# self.assertEqual(
# lines,
# [
# "3237e8c2-896d-4628-9054-59d69c785a11/add8469f-14d6-4081-8e02-adb53016f7bd/people.csv"
# ],
# )

0 comments on commit 4d51db1

Please sign in to comment.