Skip to content

Instantly share code, notes, and snippets.

View gutzbenj's full-sized avatar
🌈
think of your environment

Benjamin gutzbenj

🌈
think of your environment
View GitHub Profile
@gutzbenj
gutzbenj / google_vertex_ai_search_for_retail_as_pydantic_model.py
Last active November 26, 2024 11:17
A pydantic representation of Googles Vertex AI Search for Retail product data model (not included: collection)
"""
Below you find a pydantic model that closely represents Googles product data model for their Vertex AI Search for Retail.
Their model is closely described
- in their restapi overview: https://cloud.google.com/retail/docs/reference/rest/v2/projects.locations.catalogs.branches.products
- as proto message in code: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-retail/google/cloud/retail_v2/types/product.py
The model so far only supports product types "variant" and "primary" - which is a group of variants e.g. one productId with many skuIds.
Collections are currently not supported!
After validation product data has to be dumped `by_alias`:
@gutzbenj
gutzbenj / interpolate.py
Created February 28, 2022 11:28
Interpolate modified with polygons
# -*- coding: utf-8 -*-
# Copyright (c) 2018-2022, earthobservations developers.
# Distributed under the MIT License. See LICENSE for more info.
import logging
import numpy as np
import pandas as pd
import utm
from scipy import interpolate
@gutzbenj
gutzbenj / influxdb.py
Last active June 6, 2021 17:13
Influxdb without DataFrameClient
elif target.startswith("influxdb://"):
"""
======================
InfluxDB database sink
======================
Install Python driver::
pip install influxdb
@gutzbenj
gutzbenj / list-remote-files-dwd.py
Last active December 20, 2020 22:19
Investigate problems when scanning huge directory tree of DWD CDC HTTP server
"""
Investigate problems when scanning huge directory
tree of DWD CDC HTTP server.
This repro will show the actual files as found in the url
python list-remote-files-dwd.py | grep -v zip
"""
import os
import requests
from typing import List