Skip to content

Commit 2fec38b

Browse files
committed
fix: map
1 parent c71c38d commit 2fec38b

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

importer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ async def upload_img(path):
2323

2424
async def main():
2525
# Connect to the Label Studio API and check the connection
26+
global file
2627
lbsd = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
2728
if not lbsd.check_connection()['status'] == 'UP':
2829
print('Connection Fails! Please try again.')
@@ -32,7 +33,7 @@ async def main():
3233
for root, directory, file in os.walk(IMPORT_PATH):
3334
break
3435
response_table = []
35-
map(lambda str: IMPORT_PATH + str, file)
36+
file = list(map(lambda name: IMPORT_PATH + name, file))
3637
for uploader in asyncio.as_completed(map(upload_img, file)):
3738
response_table.append((await uploader).json())
3839
[print(item) for item in response_table]

test.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
# Get the project tasks
22

33
import requests
4+
from label_studio_sdk import Client
45
from const import LABEL_STUDIO_URL, API_KEY, EXPORT_PATH, IMPORT_PATH, PROJ_ID
56

67
headers = {
78
'Authorization': 'Token ' + API_KEY,
8-
"project": 0,
9-
"url": "",
10-
"send_payload": True,
11-
"send_for_all_actions": True,
12-
"headers": {},
13-
"is_active": True,
9+
}
10+
11+
data = {
12+
"project": "1",
13+
"url": "https://webhook.site/3cad2046-88c4-424c-b826-68e5c25361d8",
14+
"send_payload": "true",
15+
"send_for_all_actions": "true",
16+
"is_active": "true",
1417
"actions": []
1518
}
1619

1720
proxies = {
1821
'http': 'http://localhost:8080'
1922
}
2023

21-
if __name__ == 'main':
22-
response = requests.post(
23-
'http://localhost:8080/api/webhooks', headers=headers)
24+
if __name__ == '__main__':
25+
lbsd = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
26+
if not lbsd.check_connection()['status'] == 'UP':
27+
print('Connection Fails! Please try again.')
28+
else:
29+
print('Connection Succeeds!')
30+
response = requests.get(
31+
# 'http://localhost:8080/api/webhooks', headers=headers, json=data)
32+
'http://localhost:8080/api/webhooks/info')
2433
print(response.json())

0 commit comments

Comments
 (0)