Allow custom drivers and pin types

Ouverte
#315 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
python

Piste de recherche

Commencez par lire les points d’entrée existants pin_read, pin_write, pin_upload et pin_download, ainsi que la gestion des drivers officiellement pris en charge. Comparez la manière dont les types et les métadonnées sont actuellement distribués, puis examinez le handler lazyscribe lié et l’exemple de point d’entrée pour identifier les contraintes pertinentes. La tâche est terminée lorsque des drivers personnalisés peuvent être associés à des types personnalisés et utilisés via les interfaces pin_read et pin_write.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

.enhancement

I'm looking at using pins to version various model assets, but one of the pain points I'm running into is custom drivers for reading and writing. Many of our model artifacts are serialized to YAML or ONNX or a custom serialization, but there's no driver for those. There's friction too if we wanted, say a polars driver to read a csv or parquet directly into polars.

This leaves pin_upload and pin_download, which while workable, doesn't provide the same level of integration as pin_read and pin_write. If you use a user-defined helper with pin_download to read a custom type, then users have to know in advance to use that helper, versus just board.pin_read(name) for officially supported types.

For example, to show the difference in experience between a csv file and yaml:

import pandas as pd
import yaml
from pins import board_temp

board = board_temp()
data = pd.DataFrame({"a": [1,2,3]})
board.pin_write(data, "pandas_data", type="csv")

with open("data.yml", "w") as f:
    yaml.dump({"a": [1,2,3]}, f)

board.pin_upload("data.yml", name="yaml_data")

# Reading

pandas_data_read = board.pin_read("pandas_data")

yaml_path = board.pin_download("yaml_data")[0]
with open(yaml_path) as f:
    yaml_data_read = yaml.safe_load(f)

# Using helper

def pin_read_yaml(board, *args, **kwargs):
    yaml_path = board.pin_download(*args, **kwargs)[0]
    with open(yaml_path) as f:
        return yaml.safe_load(f)

yaml_helper_read = pin_read_yaml(board, "yaml_data")  # need to know in advance to use yaml, not just pin_read(name)

Optimally, I want to be able to specify custom types that are associated with custom drivers. The custom type would be written to data.txt, which would allow for dispatching to the associated driver on pin_read like is done for officially supported types, without needing to know in advance to use a user-defined helper.

I'm also seeing similarities between this problem and "dynamic artifact handling" in another library we work on (lazyscribe/lazyscribe#56), where we used handler classes and entrypoints to allow users to define custom artifact serializers/deserializers.

Anyway, please let me know if I'm missing anything here and what you think!

Langage dominant
Python
Étoiles
59
Forks
11
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de rstudio/pins-python

Toutes les issues de rstudio/pins-python

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.