%%bigquery schema_df
SELECT column_name, data_type
FROM `<dataset>.INFORMATION_SCHEMA.COLUMNS`
WHERE table_name="<table>"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
function copy_data_to_cluster () { | |
if [ "$#" -ne 2 ]; then | |
echo "ERROR: Illegal number of parameters: $#" | |
echo | |
echo "Usage:" | |
echo " $0 SRC_URI DST_URI" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_job( | |
*, | |
preset: str, | |
image: str, | |
command: str, | |
volumes: Sequence[str], | |
life_span: str = "8h", | |
name: Optional[str] = None, | |
http: Optional[int] = None, | |
no_http_auth: Optional[bool] = None, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id | summary | tsne-3d-one | tsne-3d-two | tsne-3d-three | ||
---|---|---|---|---|---|---|
0 | 75HWClTWIa1UQECeRnbjie | `La Marelle / Amarelinha` by `Dom La Nena` and `Rosemary Standley` and `Birds on a Wire` | 4.352917 | -4.418016 | 0.8423983 | |
1 | 1bTo8Nu19MuTVJXTXXjBVE | `Allant vers, à l'envers` by `Malik Djoudi` | 3.6060767 | -1.341258 | -0.4024051 | |
2 | 6j75OkiEJ1xr4RXK9AmtOd | `Ты и твоя тень` by `Увула` | -0.0042736554 | 8.795525 | 1.140939 | |
3 | 0CV0o8m5xNFvkuW3g220VQ | `Grand paon de nuit` by `Palatine` | 2.6564453 | -5.394243 | -0.014028601 | |
4 | 1gmQbUnzV4ejiBm8B9BNzQ | `Une petite fille` by `Babx` and `André Minvielle` and `Thomas de Pourquery` | -1.1268455 | 9.573206 | 1.8065826 | |
5 | 32Cfv8J3eJnPY1NP4mwBEX | `זהב לבן` by `Rona Kenan` | 3.068561 | -7.7026625 | -0.08808063 | |
6 | 094EomfUAtwLtniHpIHzzr | `מות התפוז` by `Rona Kenan` | 4.019915 | 4.552658 | -4.6062765 | |
7 | 2ntRTE4hPzWHgi0cyTySEc | `Passion` by `Aziza Mustafa Zadeh` | -3.968394 | -2.1657934 | 1.4736685 | |
8 | 2dw1gZU2QkWsiAyjBAL9ek | `Die Schlinge` by `OOMPH!` | -3.481546 | 9.903361 | 2.1730263 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: test | |
spec: | |
volumes: | |
- name: git-source | |
emptyDir: {} | |
- name: ssh-secret-volume | |
secret: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Summary: often, K8s runs an unprotected etcd server, which allows an attacker | |
# with shell access to a pod running it this cluster (it could even be a compromised | |
# server) to read all information from etcd, including K8s secrets. | |
# Step 01: on localhost: get a shell access to a pod in Kubernetes | |
$ kubectl run --image curlimages/curl -it --rm curl --command -- sh | |
# Step 02: on the pod: read data from etcd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from typing import Dict | |
def load_env(path="./.env", defaultenv=None) -> Dict[str, str]: | |
env = (defaultenv or {}).copy() | |
with open(path) as f: | |
lines = f.readlines() | |
for line in lines: | |
line = line.strip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from google.cloud.bigquery import magics | |
def get_job_statistics(job, model_name): | |
assert job.state == "DONE", job.state | |
m = client.get_model(f"{PROJECT_ID}.{DATASET}.{model_name}") | |
if len(m.training_runs) != 1: | |
print(f"WARNING: Multiple training runs (taking the first): {model}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !pip install pyyaml | |
import yaml | |
path = '/tmp/jobs.txt' | |
with open(path) as f: | |
data = list(yaml.load_all(f, Loader=yaml.FullLoader)) | |
print(len(data)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import yaml | |
# gcloud ai custom-jobs list --region=us-central1 > /tmp/jobs.txt | |
path = '/tmp/jobs.txt' | |
PROJECT_ID = "..." | |
subname = 'artem' | |