code: def write_data_set(file_path, dataset, output_dir, color_array_info, new_name=None, compress=True):
      
      fileName = new_name if new_name else os.path.basename(file_path)
      dataset_dir = os.path.join(output_dir, fileName)
      data_dir = os.path.join(dataset_dir, 'data')
  
      if not os.path.exists(data_dir):
          os.makedirs(data_dir)
  
      root = {}
      root['metadata'] = {}
      root['metadata']['name'] = fileName
  
      writer = writer_mapping[dataset.GetClassName()]
      if writer:
          writer(dataset_dir, data_dir, dataset, color_array_info, root, compress)
      else:
          print(dataObject.GetClassName(), 'is not supported')
  
      with open(os.path.join(dataset_dir, "index.json"), 'w') as f:
          f.write(json.dumps(root, indent=2))
  
      return dataset_dir
docs: write dataset to vtkjs