Skip to content

Commit 1fed2a2

Browse files
authored
Merge pull request #246 from fastlabel/bugfix/9301_encode-object-name-parameter
#9301 find_dataset_object, delete_dataset_objectに渡すobject_nameに/が含まれていると404エラーになる
2 parents 0952a65 + d672b9e commit 1fed2a2

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

examples/delete_dataset_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
client = fastlabel.Client()
44

55
client.delete_dataset_object(
6-
dataset_id="YOUR_DATASET_OBJECT_ID", object_name="YOUR_OBJECT_NAME"
6+
dataset_id="YOUR_DATASET_ID", object_name="YOUR_OBJECT_NAME"
77
)

examples/find_dataset_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
client = fastlabel.Client()
66

77
dataset_object = client.find_dataset_object(
8-
dataset_id="YOUR_DATASET_OBJECT_ID", object_name="YOUR_OBJECT_NAME"
8+
dataset_id="YOUR_DATASET_ID", object_name="YOUR_OBJECT_NAME"
99
)
1010
pprint(dataset_object)

fastlabel/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import re
6+
import urllib.parse
67
from concurrent.futures import ThreadPoolExecutor, wait
78
from pathlib import Path
89
from typing import Dict, List, Literal, Optional, Union
@@ -4251,7 +4252,10 @@ def find_dataset_object(
42514252
raise FastLabelInvalidException(
42524253
"only use specify one of revisionId or version.", 400
42534254
)
4254-
endpoint = "datasets-v2/" + dataset_id + "/objects/" + object_name
4255+
encoded_object_name = urllib.parse.quote(object_name, safe="")
4256+
endpoint = (
4257+
"dataset-objects-v2/" + dataset_id + "/objects/" + encoded_object_name
4258+
)
42554259
params = {}
42564260
if revision_id:
42574261
params["revisionId"] = revision_id
@@ -4474,7 +4478,10 @@ def delete_dataset_object(self, dataset_id: str, object_name: str) -> None:
44744478
"""
44754479
Delete a dataset object.
44764480
"""
4477-
endpoint = "datasets-v2/" + dataset_id + "/objects/" + object_name
4481+
encoded_object_name = urllib.parse.quote(object_name, safe="")
4482+
endpoint = (
4483+
"dataset-objects-v2/" + dataset_id + "/objects/" + encoded_object_name
4484+
)
44784485
self.api.delete_request(endpoint)
44794486

44804487
def update_aws_s3_storage(

0 commit comments

Comments
 (0)