Skip to content

Commit e3d75da

Browse files
Add support to declare directory, move to json for k8s
Context that current k8s ingress requires custom headers So these could get ignored And there should be way to pass directory from this method
1 parent b6569fb commit e3d75da

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

sdk/diffgram/file/file_constructor.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def file_from_response(
3939
def from_local(
4040
self,
4141
path: str,
42+
directory_id: int = None,
4243
instance_list: list = None,
4344
frame_packet_map: dict = None,
4445
assume_new_instances_machine_made: bool = True,
@@ -54,35 +55,35 @@ def from_local(
5455

5556
files = {'file': (os.path.basename(path), open(path, 'rb'), 'application/octet-stream')}
5657

57-
headers = {
58-
'immediate_mode': 'True',
59-
}
58+
json_payload = {}
59+
60+
if directory_id is None:
61+
directory_id = self.client.directory_id
6062

61-
payload = {}
63+
json_payload['directory_id'] = directory_id
6264

6365
if instance_list:
64-
payload['instance_list'] = self.__validate_and_format_instance_list(
66+
json_payload['instance_list'] = self.__validate_and_format_instance_list(
6567
instance_list = instance_list,
6668
assume_new_instances_machine_made = assume_new_instances_machine_made,
6769
convert_names_to_label_files = convert_names_to_label_files
6870
)
6971

7072
if frame_packet_map:
71-
payload['frame_packet_map'] = self.__validate_and_format_frame_packet_map(
73+
json_payload['frame_packet_map'] = self.__validate_and_format_frame_packet_map(
7274
frame_packet_map = frame_packet_map,
7375
assume_new_instances_machine_made = assume_new_instances_machine_made,
7476
convert_names_to_label_files = convert_names_to_label_files
7577
)
7678

77-
files['json'] = (None, json.dumps(payload), 'application/json')
79+
files['json'] = (None, json.dumps(json_payload), 'application/json')
7880

7981
endpoint = "/api/walrus/v1/project/" + self.client.project_string_id \
8082
+ "/input/from_local"
8183

8284
response = self.client.session.post(
8385
self.client.host + endpoint,
84-
files = files,
85-
headers = headers)
86+
files = files)
8687

8788
self.client.handle_errors(response)
8889

0 commit comments

Comments
 (0)