Skip to content

Commit

Permalink
datapoint id in query
Browse files Browse the repository at this point in the history
  • Loading branch information
sdafni committed Jan 31, 2024
1 parent 2d1ab24 commit 7239459
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
4 changes: 1 addition & 3 deletions dagshub/data_engine/client/data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,14 @@ def delete_metadata(self, datasource: Datasource, entries: List[DatapointDeleteM
assert len(entries) > 0

params = GqlMutations.delete_metadata_params(
datasource_id=datasource.source.id, datapoints=[e.to_dict() for e in entries]
datasource_id=datasource.source.id, metaDeletions=[e.to_dict() for e in entries]
)
return self._exec(q, params)


def update_metadata_fields(self, datasource: Datasource, metadata_field_props: List[MetadataFieldSchema]):
q = GqlMutations.update_metadata_field()

assert datasource.source.id is not None
# assert len(entries) > 0

params = GqlMutations.update_metadata_fields_params(
datasource_id=datasource.source.id, metadata_field_props=[e.to_dict() for e in metadata_field_props]
Expand Down
14 changes: 5 additions & 9 deletions dagshub/data_engine/client/gql_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,10 @@ def delete_metadata():
.operation(
"mutation",
name="deleteMetadata",
input={"$datasource": "ID!", "$datapoints": "[DatapointMetadataDeleteInput!]!"},
)
.query("deleteMetadata", input={"datasource": "$datasource", "datapoints": "$datapoints"})
.fields(
[
"path",
]
input={"$datasource": "ID!", "$metaDeletions": "[DatapointMetadataDeleteInput!]!"},
)
.query("deleteMetadata", input={"datasource": "$datasource", "metaDeletions": "$metaDeletions"})

.generate()
)
return q
Expand Down Expand Up @@ -98,10 +94,10 @@ def update_metadata_params(datasource_id: Union[int, str], datapoints: List[Dict
}

@staticmethod
def delete_metadata_params(datasource_id: Union[int, str], datapoints: List[Dict[str, Any]]):
def delete_metadata_params(datasource_id: Union[int, str], metaDeletions: List[Dict[str, Any]]):
return {
"datasource": datasource_id,
"datapoints": datapoints,
"metaDeletions": metaDeletions,
}

def update_metadata_fields_params(datasource_id: Union[int, str], metadata_field_props: List[Dict[str, Any]]):
Expand Down
2 changes: 1 addition & 1 deletion dagshub/data_engine/model/datapoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __setitem__(self, key, value):
self.datasource.implicit_update_context.update_metadata(self.path, {key: value})

def delete_metadata(self, name):
self.datasource.delete_metadata(self.path, name)
self.datasource.delete_metadata(self.path, self.datapoint_id, name)

def save(self):
"""
Expand Down
5 changes: 3 additions & 2 deletions dagshub/data_engine/model/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DatapointMetadataUpdateEntry(json.JSONEncoder):
@dataclass_json
@dataclass
class DatapointDeleteMetadataEntry(json.JSONEncoder):
datapointId: str
url: str
key: str

Expand Down Expand Up @@ -550,8 +551,8 @@ def _upload_metadata(self, metadata_entries: List[DatapointMetadataUpdateEntry])
# Update the status from dagshub, so we get back the new metadata columns
self.source.get_from_dagshub()

def delete_metadata(self, path, key):
metadata_entries = [DatapointDeleteMetadataEntry(url=path, key=key)]
def delete_metadata(self, path, id, key):
metadata_entries = [DatapointDeleteMetadataEntry(datapointId=id, url=path, key=key)]

Check failure on line 555 in dagshub/data_engine/model/datasource.py

View workflow job for this annotation

GitHub Actions / Flake8

dagshub/data_engine/model/datasource.py#L555

Multiple spaces after ',' (E241)
self.source.client.delete_metadata(self, metadata_entries)

# Update the status from dagshub, so we get back the new metadata columns
Expand Down

0 comments on commit 7239459

Please sign in to comment.