parsagon 0.9.5__py3-none-any.whl → 0.9.7__py3-none-any.whl
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.
- parsagon/api.py +2 -2
- parsagon/main.py +15 -2
- {parsagon-0.9.5.dist-info → parsagon-0.9.7.dist-info}/METADATA +1 -1
- {parsagon-0.9.5.dist-info → parsagon-0.9.7.dist-info}/RECORD +7 -7
- {parsagon-0.9.5.dist-info → parsagon-0.9.7.dist-info}/WHEEL +0 -0
- {parsagon-0.9.5.dist-info → parsagon-0.9.7.dist-info}/entry_points.txt +0 -0
- {parsagon-0.9.5.dist-info → parsagon-0.9.7.dist-info}/top_level.txt +0 -0
parsagon/api.py
CHANGED
@@ -149,11 +149,11 @@ def create_custom_function(pipeline_id, call_id, custom_function):
|
|
149
149
|
)
|
150
150
|
|
151
151
|
|
152
|
-
def add_examples_to_custom_function(pipeline_id, call_id, custom_function):
|
152
|
+
def add_examples_to_custom_function(pipeline_id, call_id, custom_function, remove_old_examples):
|
153
153
|
_api_call(
|
154
154
|
httpx.post,
|
155
155
|
"/transformers/custom-function/add-examples/",
|
156
|
-
json={"pipeline": pipeline_id, "call_id": call_id, **custom_function.to_json()},
|
156
|
+
json={"pipeline": pipeline_id, "call_id": call_id, "remove_old_examples": remove_old_examples, **custom_function.to_json()},
|
157
157
|
)
|
158
158
|
|
159
159
|
|
parsagon/main.py
CHANGED
@@ -103,6 +103,11 @@ def get_args():
|
|
103
103
|
action="store_true",
|
104
104
|
help="let Parsagon infer all elements to be scraped",
|
105
105
|
)
|
106
|
+
parser_update.add_argument(
|
107
|
+
"--replace",
|
108
|
+
action="store_true",
|
109
|
+
help="remove old example data while updating the program",
|
110
|
+
)
|
106
111
|
parser_update.set_defaults(func=update)
|
107
112
|
|
108
113
|
# Run
|
@@ -233,7 +238,7 @@ def create(task=None, program_name=None, headless=False, infer=False, verbose=Fa
|
|
233
238
|
logger.info("Done.")
|
234
239
|
|
235
240
|
|
236
|
-
def update(program_name, variables={}, headless=False, infer=False, verbose=False):
|
241
|
+
def update(program_name, variables={}, headless=False, infer=False, replace=False, verbose=False):
|
237
242
|
pipeline = get_pipeline(program_name)
|
238
243
|
abridged_program = pipeline["abridged_sketch"]
|
239
244
|
# Make the program runnable
|
@@ -245,6 +250,14 @@ def update(program_name, variables={}, headless=False, infer=False, verbose=Fals
|
|
245
250
|
executor = Executor(headless=headless, infer=infer)
|
246
251
|
executor.execute(abridged_program)
|
247
252
|
|
253
|
+
while True:
|
254
|
+
program_name_input = input(f"Type \"{program_name}\" to update this program, or press enter without typing a name to CANCEL: ")
|
255
|
+
if not program_name_input:
|
256
|
+
logger.info("Canceled update.")
|
257
|
+
return
|
258
|
+
if program_name_input == program_name:
|
259
|
+
break
|
260
|
+
|
248
261
|
pipeline_id = pipeline["id"]
|
249
262
|
try:
|
250
263
|
for call_id, custom_function in executor.custom_functions.items():
|
@@ -254,7 +267,7 @@ def update(program_name, variables={}, headless=False, infer=False, verbose=Fals
|
|
254
267
|
if verbose:
|
255
268
|
description += debug_suffix
|
256
269
|
logger.info(f" Saving function{description}...")
|
257
|
-
add_examples_to_custom_function(pipeline_id, call_id, custom_function)
|
270
|
+
add_examples_to_custom_function(pipeline_id, call_id, custom_function, replace)
|
258
271
|
logger.info(f"Saved.")
|
259
272
|
except Exception as e:
|
260
273
|
print(e)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
parsagon/__init__.py,sha256=YRvTX1ekTKcPXTKXLgr6-CrRC0DFc11L3gFSPI_Ohc8,54
|
2
|
-
parsagon/api.py,sha256=
|
2
|
+
parsagon/api.py,sha256=yy_82ZvZU7ytl9t02lskeMGAoYLUQTBFr6Zo8F-4Vgo,6292
|
3
3
|
parsagon/custom_function.py,sha256=oEj28qItaHUnsvLIHD7kg5QL3J3aO6rW6xKKP-H-Drs,770
|
4
4
|
parsagon/exceptions.py,sha256=NYpFaSLZplBTv9fov_1LKPzDPIqb7Ffe7IunnjntxvA,819
|
5
5
|
parsagon/executor.py,sha256=lkV9KvljNH-9nQwIxZbGJMSbKkU7MzeI6yiGxBQo1C0,15759
|
6
6
|
parsagon/highlights.js,sha256=eLzQT7UABVLLinvWfnXruHjCKZK9If3w742VsoMCO_o,14871
|
7
|
-
parsagon/main.py,sha256=
|
7
|
+
parsagon/main.py,sha256=vL1-MJPAO5yASFk0B3iAymA8u7dNfUqpLerhQ0PMi5A,11818
|
8
8
|
parsagon/settings.py,sha256=s5_MsDMFM5tB8U8tfHaFnKibCoEqPnAu8b_ueg07Ftw,2947
|
9
9
|
parsagon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
parsagon/tests/api_mocks.py,sha256=M8xhiyPa1dI8Vx-odDk7ETopfFAfcjfAf-ApmSqgvfw,3127
|
@@ -13,8 +13,8 @@ parsagon/tests/conftest.py,sha256=KMlHohc0QT77HzumraIojzKeqroyxarnaT6naJDNvEc,42
|
|
13
13
|
parsagon/tests/test_executor.py,sha256=n3cmh84r74siSeJqUeAIwjjnNzDVPEdxcvYAeJ4hNX8,645
|
14
14
|
parsagon/tests/test_invalid_args.py,sha256=kOjMpbZvviR1CwvXReteZMxBvuhq_rOv5Tm1muBSzNk,676
|
15
15
|
parsagon/tests/test_pipeline_operations.py,sha256=TpBKCuRA8LHYWx3PD_k9mYCSsA_9SZjrOX-rS4mE8XE,1089
|
16
|
-
parsagon-0.9.
|
17
|
-
parsagon-0.9.
|
18
|
-
parsagon-0.9.
|
19
|
-
parsagon-0.9.
|
20
|
-
parsagon-0.9.
|
16
|
+
parsagon-0.9.7.dist-info/METADATA,sha256=D75z0KUZFsoWY-JoY_FZIpSZxfR_D7VGru0aepBnFhc,2260
|
17
|
+
parsagon-0.9.7.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
18
|
+
parsagon-0.9.7.dist-info/entry_points.txt,sha256=I1UlPUb4oY2k9idkI8kvdkEcrjKGRSOl5pMbA6uu6kw,48
|
19
|
+
parsagon-0.9.7.dist-info/top_level.txt,sha256=ih5uYQzW4qjhRKppys-WiHLIbXVZ99YdqDcfAtlcQwk,9
|
20
|
+
parsagon-0.9.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|