Skip to content

Commit ed4d850

Browse files
Merge pull request #14 from diffgram/fix-permissions-on-file-exists
fix condition
2 parents 8e1c826 + 85baf16 commit ed4d850

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

sdk/diffgram/core/core.py

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from diffgram.brain.train import Train
1818
from diffgram.export.export import Export
1919
from diffgram.task.task import Task
20+
from requests.auth import HTTPBasicAuth
2021

2122

2223
class Project():
@@ -73,6 +74,9 @@ def get_member_list(self):
7374
data = response.json()
7475
return data['project']['member_list']
7576

77+
def get_http_auth(self):
78+
return HTTPBasicAuth(self.client_id, self.client_secret)
79+
7680
def get_label(
7781
self,
7882
name=None,

sdk/diffgram/core/diffgram_dataset_iterator.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ def __next__(self):
8787
def __validate_file_ids(self):
8888
if not self.diffgram_file_id_list:
8989
return
90-
result = self.project.file.file_list_exists(self.diffgram_file_id_list, use_session = False)
90+
result = self.project.file.file_list_exists(
91+
self.diffgram_file_id_list,
92+
use_session = False)
9193
if not result:
9294
raise Exception(
9395
'Some file IDs do not belong to the project. Please provide only files from the same project.')

sdk/diffgram/file/file_constructor.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import json
66
import os
77
import requests
8-
from requests.auth import HTTPDigestAuth
98

109
class FileConstructor():
1110
"""
@@ -422,7 +421,7 @@ def file_list_exists(self, id_list, use_session = True):
422421
response = requests.post(
423422
url = self.client.host + url,
424423
json = spec_dict,
425-
auth = HTTPDigestAuth(self.client.client_id, self.client.client_secret)
424+
auth = self.client.get_http_auth()
426425
)
427426
self.client.handle_errors(response)
428427

@@ -466,7 +465,7 @@ def get_by_id(self,
466465
# Add Auth
467466
response = requests.post(self.client.host + endpoint,
468467
json = spec_dict,
469-
auth = HTTPDigestAuth(self.client.client_id, self.client.client_secret))
468+
auth = self.client.get_http_auth())
470469

471470
self.client.handle_errors(response)
472471

sdk/diffgram/file/view.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import requests
2-
from requests.auth import HTTPDigestAuth
32

43

54
def get_file_id():
@@ -49,7 +48,7 @@ def get_label_file_dict(self, use_session = True):
4948
# Add Auth
5049
response = requests.get(self.host + endpoint,
5150
headers = {'directory_id': str(self.directory_id)},
52-
auth = HTTPDigestAuth(self.client_id, self.client_secret))
51+
auth = self.client.get_http_auth())
5352

5453
self.handle_errors(response)
5554

0 commit comments

Comments
 (0)