from google.colab import auth
# auth.authenticate_user()

!curl https://sdk.cloud.google.com | bash

!gcloud init

!gcloud config set project "kablj-ml"

# !gsutil -m cp -R gs://deepmind-research-glassy-dynamics .

!gsutil -m ls -al gs://deepmind-research-glassy-dynamics

!gsutil -m ls -la gs://deepmind-research-glassy-dynamics/public_dataset/

!gsutil -m ls -al gs://deepmind-research-glassy-dynamics/public_dataset/AQS/train | tail -n 1

!gsutil -m ls -al gs://deepmind-research-glassy-dynamics/public_dataset/temperature_044/train | tail -n 1

!gsutil -m ls -al gs://deepmind-research-glassy-dynamics/public_dataset/temperature_04685/train | tail -n 1

!gsutil -m ls -al gs://deepmind-research-glassy-dynamics/public_dataset/temperature_050/train | tail -n 1

!gsutil -m ls -al gs://deepmind-research-glassy-dynamics/public_dataset/temperature_056/train | tail -n 1

!gsutil -m cp -R gs://deepmind-research-glassy-dynamics/public_dataset/temperature_044/train .

import pickle
import os
import tensorflow as tf

files = os.walk("./train")
base, _, lst = next(files)
files = [os.path.join(base, l) for l in lst]

with tf.io.gfile.GFile(files[0], 'rb') as f:
  data = pickle.load(f)

print("Type : ", type(data))
print("Keys : ", ", \n\t".join([k for k in data]))
print("Key Iterated : ")
for k in data:
  print("\t", k, " : ", type(data[k]))

print("METADATA")
print(data['metadata'])

with tf.io.gfile.GFile(files[0], 'rb') as f:
  data = pickle.load(f)
  time_indices = data['time_indices']
  time = data ['time']
  print(time_indices)
  for time_now in time_indices:
    print(time[time_now])

with tf.io.gfile.GFile(files[1], 'rb') as f:
  data = pickle.load(f)
  time_indices = data['time_indices']
  time = data ['time']
  print(time_indices)
  for time_now in time_indices:
    print(time[time_now])

with tf.io.gfile.GFile(files[2], 'rb') as f:
  data = pickle.load(f)
  time_indices = data['time_indices']
  time = data ['time']
  print(time_indices)
  for time_now in time_indices:
    print(time[time_now])

with tf.io.gfile.GFile(files[3], 'rb') as f:
  data = pickle.load(f)
  time_indices = data['time_indices']
  time = data ['time']
  print(time_indices)
  for time_now in time_indices:
    print(time[time_now])

