Skip to content

Commit 698364c

Browse files
committed
tmp
1 parent 4c5f48f commit 698364c

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/apify/storage_clients/_apify/_dataset_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ async def open(
126126
# Normalize 'default' alias to None
127127
alias = None if alias == 'default' else alias
128128

129+
logger.info(f'Opening dataset with id={id}, name={name}, and alias={alias}')
130+
129131
# Handle alias resolution
130132
if alias:
131133
# Try to resolve alias to existing storage ID

src/apify/storage_clients/_apify/_utils.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ async def resolve_alias_to_id(
3737

3838
try:
3939
record = await default_kvs_client.get_record(_ALIAS_MAPPING_KEY)
40+
logger.info(f'resolving record: {record}')
4041

41-
if isinstance(record, dict) and alias_key in record:
42-
return str(record[alias_key])
42+
# Extract the actual data from the KVS record
43+
alias_data = record.get('value') if isinstance(record, dict) else record
44+
45+
if isinstance(alias_data, dict) and alias_key in alias_data:
46+
return str(alias_data[alias_key])
4347

4448
except Exception as exc:
4549
# If there's any error accessing the record, treat it as not found
@@ -69,15 +73,19 @@ async def store_alias_mapping(
6973

7074
try:
7175
record = await default_kvs_client.get_record(_ALIAS_MAPPING_KEY)
76+
logger.info(f'storing record: {record}')
77+
78+
# Extract the actual data from the KVS record
79+
alias_data = record.get('value') if isinstance(record, dict) else None
7280

7381
# Update or create the record with the new alias mapping
74-
if isinstance(record, dict) and alias_key in record:
75-
record[alias_key] = storage_id
82+
if isinstance(alias_data, dict):
83+
alias_data[alias_key] = storage_id
7684
else:
77-
record = {alias_key: storage_id}
85+
alias_data = {alias_key: storage_id}
7886

7987
# Store the mapping back in the KVS.
80-
await default_kvs_client.set_record(_ALIAS_MAPPING_KEY, record)
88+
await default_kvs_client.set_record(_ALIAS_MAPPING_KEY, alias_data)
8189
except Exception as exc:
8290
logger.warning(f'Error accessing alias mapping for {alias}: {exc}')
8391

0 commit comments

Comments
 (0)