davanstrien HF staff commited on
Commit
ad7b3f8
1 Parent(s): 247c500

Refactor datasets_server_valid_rows function to handle response from datasets server

Browse files
Files changed (1) hide show
  1. main.py +2 -1
main.py CHANGED
@@ -58,7 +58,8 @@ TARGET_COLUMN_NAMES = {
58
  def datasets_server_valid_rows(hub_id: str):
59
  try:
60
  resp = client.get(f"{BASE_DATASETS_SERVER_URL}/is-valid?dataset={hub_id}")
61
- return resp.json()["viewer"]
 
62
  except Exception as e:
63
  logger.error(f"Failed to get is-valid for {hub_id}: {e}")
64
  return False
 
58
  def datasets_server_valid_rows(hub_id: str):
59
  try:
60
  resp = client.get(f"{BASE_DATASETS_SERVER_URL}/is-valid?dataset={hub_id}")
61
+ data = resp.json()
62
+ return True if data.get("viewer") else bool(data.get("preview"))
63
  except Exception as e:
64
  logger.error(f"Failed to get is-valid for {hub_id}: {e}")
65
  return False