apify 2.7.1b14__py3-none-any.whl → 2.7.1b15__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.

Potentially problematic release.


This version of apify might be problematic. Click here for more details.

@@ -1,4 +1,6 @@
1
1
  import asyncio
2
+ import json
3
+ from pathlib import Path
2
4
 
3
5
  from typing_extensions import override
4
6
 
@@ -23,9 +25,15 @@ class ApifyFileSystemKeyValueStoreClient(FileSystemKeyValueStoreClient):
23
25
  the `INPUT.json` file. It also updates the metadata to reflect that the store has been purged.
24
26
  """
25
27
  kvs_input_key = Configuration.get_global_configuration().input_key
28
+
29
+ # First try to find the alternative format of the input file and process it if it exists.
30
+ for file_path in self.path_to_kvs.glob('*'):
31
+ if file_path.name == f'{kvs_input_key}.json':
32
+ await self._process_input_json(file_path)
33
+
26
34
  async with self._lock:
27
35
  for file_path in self.path_to_kvs.glob('*'):
28
- if file_path.name in {METADATA_FILENAME, f'{kvs_input_key}.json'}:
36
+ if file_path.name in {METADATA_FILENAME, kvs_input_key, f'{kvs_input_key}.{METADATA_FILENAME}'}:
29
37
  continue
30
38
  if file_path.is_file():
31
39
  await asyncio.to_thread(file_path.unlink, missing_ok=True)
@@ -34,3 +42,16 @@ class ApifyFileSystemKeyValueStoreClient(FileSystemKeyValueStoreClient):
34
42
  update_accessed_at=True,
35
43
  update_modified_at=True,
36
44
  )
45
+
46
+ async def _process_input_json(self, path: Path) -> None:
47
+ """Process simple input json file to format expected by the FileSystemKeyValueStoreClient.
48
+
49
+ For example: INPUT.json -> INPUT, INPUT.json.metadata
50
+ """
51
+ try:
52
+ f = await asyncio.to_thread(path.open)
53
+ input_data = json.load(f)
54
+ finally:
55
+ f.close()
56
+ await asyncio.to_thread(path.unlink, missing_ok=True)
57
+ await self.set_value(key=path.stem, value=input_data)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apify
3
- Version: 2.7.1b14
3
+ Version: 2.7.1b15
4
4
  Summary: Apify SDK for Python
5
5
  Project-URL: Apify Homepage, https://apify.com
6
6
  Project-URL: Changelog, https://docs.apify.com/sdk/python/docs/changelog
@@ -42,11 +42,11 @@ apify/storage_clients/_apify/_request_queue_client.py,sha256=LuKH_7Y9TMU1qtSagWR
42
42
  apify/storage_clients/_apify/_storage_client.py,sha256=5me6gHOeNAG3JaHxKRdzsZaa3FsqLDbObjhECGGWrr4,2890
43
43
  apify/storage_clients/_apify/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  apify/storage_clients/_file_system/__init__.py,sha256=rDbXatXV9wHKPhKTrXDzWnexhTm7sIJQWucMi-P-SD4,130
45
- apify/storage_clients/_file_system/_key_value_store_client.py,sha256=DHDv_e0kFwhBCIXUadZAamHhUao3NsSniUEXgnttnVY,1430
45
+ apify/storage_clients/_file_system/_key_value_store_client.py,sha256=fnSJ1EIOPCGfcE6e5S3Tux9VbnMVLCJjugkaQoH_9yo,2267
46
46
  apify/storage_clients/_file_system/_storage_client.py,sha256=UwxuSvhbyQ7zR1db1hTmZ1h38yH7btHNp82X7e8MWWE,1290
47
47
  apify/storages/__init__.py,sha256=-9tEYJVabVs_eRVhUehxN58GH0UG8OfuGjGwuDieP2M,122
48
48
  apify/storages/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
- apify-2.7.1b14.dist-info/METADATA,sha256=hKa1ufnBfaSa3vq9dx0zm36o9q3o1iD5IqIH9P992y8,22579
50
- apify-2.7.1b14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
51
- apify-2.7.1b14.dist-info/licenses/LICENSE,sha256=AsFjHssKjj4LGd2ZCqXn6FBzMqcWdjQre1byPPSypVw,11355
52
- apify-2.7.1b14.dist-info/RECORD,,
49
+ apify-2.7.1b15.dist-info/METADATA,sha256=Pnzk7qNSYZPx9Yjv3hg_Ua2zfTcbr_4VfM6I0duOIrY,22579
50
+ apify-2.7.1b15.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
51
+ apify-2.7.1b15.dist-info/licenses/LICENSE,sha256=AsFjHssKjj4LGd2ZCqXn6FBzMqcWdjQre1byPPSypVw,11355
52
+ apify-2.7.1b15.dist-info/RECORD,,