Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Creating Docker artifacts for a Google Cloud Storage bucket

未关闭
#240 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
docker, gcp, python
领域
cloud, devops

调研方向

相关入口点位于 vetiver/attach_pkgs.py 的第 74-75 行;复现 board_gcs/prepare_docker 流程,并检查 ('gs', 'gcs') 协议如何映射到软件包要求。完成的标准是生成的 vetiver_requirements.txt 包含 gcsfs,并且生成的容器能够启动。

由索引模型根据 Issue 内容生成。

描述

bug deploy pins

Describe the bug

Seems to be a repeat of #165. I want to create Docker artifacts for a model stored on a GCS bucket, but the gcsfs package is not being listed in the vetiver_requirements.txt file so Docker cannot run the container.

To Reproduce

Create and store a model on a GCS bucket, and generate the required Docker artifacts. I used

import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from pins import board_gcs
from vetiver import VetiverModel, vetiver_pin_write, prepare_docker
from dotenv import load_dotenv
import os

# Load environment variables from .env file
load_dotenv()

# Load Palmer Penguins dataset
url = "https://raw.githubusercontent.com/allisonhorst/palmerpenguins/master/inst/extdata/penguins.csv"
penguins = pd.read_csv(url)

# Drop rows with missing values
penguins = penguins.dropna()

# Select features and target
X = penguins[["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"]]
y = penguins["body_mass_g"]

# Split into train and test sets
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

# Fit linear regression model
model = LinearRegression()
model.fit(X_train, y_train)

# Create Vetiver model
v = VetiverModel(model, "penguins-test", prototype_data = X_train)

# Store on board
board = board_gcs("info-4940-models/test/", cache=None, allow_pickle_read=True)
vetiver_pin_write(board, v)

# Create Docker artifacts
prepare_docker(
    board, 
    "penguins-test",
    path = "~/Desktop/penguins-test"
)

Note that prepare_docker() included this warning

/Users/bcs88/Projects/info-4940/assessments/.venv/lib/python3.13/site-packages/vetiver/attach_pkgs.py:77: UserWarning: required packages unknown for board protocol: ('gs', 'gcs'), add to model's metadata to export

I then built and ran the Docker container.

docker build -t penguins .
docker run -p 8080:8080 penguins

Which generated this output

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/fsspec/registry.py", line 261, in get_filesystem_class
    register_implementation(protocol, _import_class(bit["class"]))
                                      ~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/fsspec/registry.py", line 296, in _import_class
    mod = importlib.import_module(mod)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'gcsfs'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/uvicorn", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1462, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1383, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 1246, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.13/site-packages/uvicorn/main.py", line 423, in main
    run(
    ~~~^
        app,
        ^^^^
    ...<46 lines>...
        h11_max_incomplete_event_size=h11_max_incomplete_event_size,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/uvicorn/main.py", line 593, in run
    server.run()
    ~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/uvicorn/server.py", line 67, in run
    return asyncio_run(self.serve(sockets=sockets), loop_factory=self.config.get_loop_factory())
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/uvicorn/server.py", line 71, in serve
    await self._serve(sockets)
  File "/usr/local/lib/python3.13/site-packages/uvicorn/server.py", line 78, in _serve
    config.load()
    ~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/uvicorn/config.py", line 439, in load
    self.loaded_app = import_from_string(self.app)
                      ~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/uvicorn/importer.py", line 19, in import_from_string
    module = importlib.import_module(module_str)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1027, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/vetiver/app/app.py", line 8, in <module>
    b = pins.board_gcs('info-4940-models/test/', allow_pickle_read=True)
  File "/usr/local/lib/python3.13/site-packages/pins/constructors.py", line 542, in board_gcs
    return board("gcs", path, versioned, cache, allow_pickle_read, storage_options=opts)
  File "/usr/local/lib/python3.13/site-packages/pins/constructors.py", line 97, in board
    fs = fsspec.filesystem(protocol, **storage_options)
  File "/usr/local/lib/python3.13/site-packages/fsspec/registry.py", line 321, in filesystem
    cls = get_filesystem_class(protocol)
  File "/usr/local/lib/python3.13/site-packages/fsspec/registry.py", line 263, in get_filesystem_class
    raise ImportError(bit.get("err")) from e
ImportError: Please install gcsfs to access Google Storage

As expected since gcsfs is not listed in the vetiver_requirements.txt.

Expected behavior

I expected gcsfs to be automatically included in the requirements file. I can edit the file manually to add the requirement and then I can successfully build and run the container. But I thought #166 automated this step.

Desktop (please complete the following information):

Positron Version: 2025.10.1 build 4
Code - OSS Version: 1.103.0
Commit: b13dd1ca4803bc04a4a9165395b589b8caf4ab58
Date: 2025-10-14T21:43:42.876Z
Electron: 37.2.3
Chromium: 138.0.7204.100
Node.js: 22.17.0
V8: 13.8.500258-electron.0
OS: Darwin arm64 25.0.0

I confirmed I am using 0.2.6 which should include #166.

pip show vetiver
Name: vetiver
Version: 0.2.6
Summary: Version, share, deploy, and monitor models.
Home-page: https://github.com/rstudio/vetiver-python
Author: 
Author-email: Isabel Zimmerman <[email protected]>
License: MIT
Location: /Users/bcs88/Projects/info-4940/assessments/.venv/lib/python3.13/site-packages
Requires: fastapi, httpx, joblib, nest-asyncio, numpy, pandas, pins, pip-tools, plotly, pydantic, python-dotenv, requests, rsconnect-python, scikit-learn, uvicorn
Required-by: 

Additional context

Only thing that sticks out to me is

UserWarning: required packages unknown for board protocol: ('gs', 'gcs'), add to model's metadata to export

Which lists the protocols in reverse order compared to attach_pkgs.py.

https://github.com/rstudio/vetiver-python/blob/abb17c0fcdd9fa09e4dfe9e1d35aa02d35c67b91/vetiver/attach_pkgs.py#L74-L75

But I am primarily an R user, so I don't know if the order matters.

主要语言
Python
星标
71
派生
20
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rstudio/vetiver-python 的其他 Issue

查看 rstudio/vetiver-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。