lcpcli 0.3.1__tar.gz → 0.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lcpcli-0.3.1 → lcpcli-0.3.2}/PKG-INFO +2 -2
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/__init__.py +1 -1
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/builder.py +3 -1
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/lcp_upload.py +24 -14
- {lcpcli-0.3.1 → lcpcli-0.3.2}/.gitignore +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/LICENSE.txt +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/README.md +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/__main__.py +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/check_files.py +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/cli.py +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/conllu_builder.py +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/corpert.py +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/free_video_corpus/input/doc.conllu +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/free_video_corpus/input/meta.json +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/free_video_corpus/input/namedentity.csv +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/free_video_corpus/input/shot.csv +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/free_video_corpus/output/media/bunny.mp4 +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/input/in.conllu +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/input/in.vert +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/input/in_tei_spoken.xml +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/data/lcp_corpus_template.json +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/lcpcli.py +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/lcpcli/utils.py +0 -0
- {lcpcli-0.3.1 → lcpcli-0.3.2}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: lcpcli
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Helper for converting CONLLU files and uploading the corpus to LiRI Corpus Platform (LCP)
|
|
5
5
|
Project-URL: Homepage, https://github.com/liri-uzh/lcpcli
|
|
6
6
|
Project-URL: Issues, https://github.com/liri-uzh/lcpcli/issues
|
|
@@ -167,6 +167,7 @@ class Corpus:
|
|
|
167
167
|
revision: int | float = 1,
|
|
168
168
|
url: str = "placeholder",
|
|
169
169
|
license: str | None = None,
|
|
170
|
+
tmp_dir: str | None = None,
|
|
170
171
|
):
|
|
171
172
|
self._name = name
|
|
172
173
|
self._document = document
|
|
@@ -184,10 +185,11 @@ class Corpus:
|
|
|
184
185
|
self._url = url
|
|
185
186
|
self._license = license
|
|
186
187
|
self._upperFrameDocument = 0
|
|
188
|
+
self._tmp_dir = tmp_dir
|
|
187
189
|
|
|
188
190
|
def _csv_writer(self, fn: str):
|
|
189
191
|
tmp = tempfile.NamedTemporaryFile(
|
|
190
|
-
"w+", encoding="utf-8", newline="\n", delete=False
|
|
192
|
+
"w+", encoding="utf-8", newline="\n", delete=False, dir=self._tmp_dir
|
|
191
193
|
)
|
|
192
194
|
self._files[fn] = tmp
|
|
193
195
|
return csv.writer(tmp)
|
|
@@ -57,10 +57,25 @@ class CustomUploader(tus_uploader.Uploader):
|
|
|
57
57
|
if metadata:
|
|
58
58
|
self.metadata = metadata
|
|
59
59
|
self.client.headers.update(headers)
|
|
60
|
-
self.last_post_headers =
|
|
60
|
+
self.last_post_headers = {}
|
|
61
|
+
self.tqdm = tqdm(
|
|
62
|
+
total=self.get_file_size(),
|
|
63
|
+
desc=f"Uploading {self.metadata.get('filename', 'file')}",
|
|
64
|
+
unit_scale=True,
|
|
65
|
+
ncols=100,
|
|
66
|
+
leave=False,
|
|
67
|
+
)
|
|
61
68
|
|
|
62
69
|
def _do_request(self):
|
|
63
70
|
super()._do_request()
|
|
71
|
+
offset = self.get_offset()
|
|
72
|
+
total_size = self.get_file_size()
|
|
73
|
+
if offset < total_size:
|
|
74
|
+
self.tqdm.n = offset
|
|
75
|
+
self.tqdm.refresh()
|
|
76
|
+
else:
|
|
77
|
+
self.tqdm.close()
|
|
78
|
+
self.tqdm.clear()
|
|
64
79
|
try:
|
|
65
80
|
self.last_post_headers = self.request.response_headers
|
|
66
81
|
except:
|
|
@@ -415,7 +430,7 @@ def lcp_upload(
|
|
|
415
430
|
)
|
|
416
431
|
|
|
417
432
|
if status != "finished":
|
|
418
|
-
print(f"Upload failed: {error}")
|
|
433
|
+
print(f"Upload failed: {status} - {error}")
|
|
419
434
|
else:
|
|
420
435
|
if overwrite_id and overwrite_id > 0:
|
|
421
436
|
status, error_or_job_id = overwrite_corpus(
|
|
@@ -524,7 +539,8 @@ def send_media(
|
|
|
524
539
|
uploader = tus_client.uploader(
|
|
525
540
|
file_path, chunk_size=1000 * 1024, headers=headers
|
|
526
541
|
)
|
|
527
|
-
|
|
542
|
+
# No request object so no response.headers for 0-bit files: set 'finished' manually
|
|
543
|
+
data = uploader.upload() or {"x-status": "finished"}
|
|
528
544
|
print(f"✅ Uploaded {file_path} to: {uploader.url}")
|
|
529
545
|
except Exception as e:
|
|
530
546
|
return ("failed", str(e))
|
|
@@ -660,17 +676,11 @@ def check_template_and_send(
|
|
|
660
676
|
)
|
|
661
677
|
data = uploader.upload()
|
|
662
678
|
print(f"✅ Uploaded {file_path} to: {uploader.url}")
|
|
663
|
-
# resp = post(upload_url, params=jso, headers=headers, files=files, verify=False) # type: ignore
|
|
664
679
|
|
|
665
680
|
time.sleep(0.5)
|
|
666
681
|
|
|
667
682
|
print("Waiting for server checks...")
|
|
668
683
|
|
|
669
|
-
# try:
|
|
670
|
-
# data = resp.json()
|
|
671
|
-
# except Exception:
|
|
672
|
-
# print("Error", resp)
|
|
673
|
-
|
|
674
684
|
if "x-target" not in data:
|
|
675
685
|
print(f"Failed:")
|
|
676
686
|
for k, v in data.items():
|
|
@@ -686,7 +696,7 @@ def monitor_db_insert(
|
|
|
686
696
|
new_url: str, headers: dict[str, Any], jso: dict[str, Any]
|
|
687
697
|
) -> int:
|
|
688
698
|
"""
|
|
689
|
-
Poll /
|
|
699
|
+
Poll /monitor_db_insert and check the status of a job
|
|
690
700
|
"""
|
|
691
701
|
status = None
|
|
692
702
|
wait = 8
|
|
@@ -696,7 +706,7 @@ def monitor_db_insert(
|
|
|
696
706
|
unit: str = "byte"
|
|
697
707
|
|
|
698
708
|
while True:
|
|
699
|
-
resp =
|
|
709
|
+
resp = requests.get(new_url, headers=headers)
|
|
700
710
|
data = resp.json()
|
|
701
711
|
|
|
702
712
|
if data.get("status") != status and data["status"] not in bads:
|
|
@@ -770,9 +780,9 @@ def check_template(
|
|
|
770
780
|
|
|
771
781
|
while True:
|
|
772
782
|
if not status or not (elapsed * 10 % wait):
|
|
773
|
-
|
|
774
|
-
cparams = {"
|
|
775
|
-
resp = post(
|
|
783
|
+
status_url = url.removesuffix("/") + data["target"]
|
|
784
|
+
cparams = {"project": project}
|
|
785
|
+
resp = post(status_url, params=cparams, headers=headers) # type: ignore
|
|
776
786
|
data = resp.json()
|
|
777
787
|
if data.get("status") != status:
|
|
778
788
|
print("")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|