full-evening-87657
11/24/2023, 7:54 AMimport typing
import pandas as pd
from flytekit import ImageSpec, Resources, task, workflow
pandas_image_spec = ImageSpec(
base_image="ghcr.io/flyteorg/flytekit:py3.9-latest",
packages=["pandas", "numpy"],
python_version="3.9",
apt_packages=["git"],
env={"Debug": "True"},
registry="ghcr.io/flyteorg",
)
sklearn_image_spec = ImageSpec(
base_image="ghcr.io/flyteorg/flytekit:py3.9-latest",
packages=["scikit-learn"],
registry="ghcr.io/flyteorg",
)
if sklearn_image_spec.is_container():
from sklearn.linear_model import LogisticRegression
@task(container_image=pandas_image_spec)
def get_pandas_dataframe() -> typing.Tuple[pd.DataFrame, pd.Series]:
df = pd.read_csv("<https://storage.googleapis.com/download.tensorflow.org/data/heart.csv>")
print(df.head())
return df[["age", "thalach", "trestbps", "chol", "oldpeak"]], df.pop("target")
@task(container_image=sklearn_image_spec, requests=Resources(cpu="1", mem="1Gi"))
def get_model(max_iter: int, multi_class: str) -> typing.Any:
return LogisticRegression(max_iter=max_iter, multi_class=multi_class)
# Get a basic model to train.
@task(container_image=sklearn_image_spec, requests=Resources(cpu="1", mem="1Gi"))
def train_model(model: typing.Any, feature: pd.DataFrame, target: pd.Series) -> typing.Any:
model.fit(feature, target)
return model
# Lastly, let's define a workflow to capture the dependencies between the tasks.
@workflow()
def wf():
feature, target = get_pandas_dataframe()
model = get_model(max_iter=3000, multi_class="auto")
train_model(model=model, feature=feature, target=target)
if __name__ == "__main__":
wf()
When i register the wf
pyflyte register workflows/image_spec.py
Image ghcr.io/flyteorg/flytekit:3ADTed3jxN2hwtMwkTdzmA.. not found. Building...
Run command: envd build --path /tmp/flyte-mtww9jz_/sandbox/local_flytekit/d5987e0040556b03793dfa6877733305 --platform linux/amd64 --output type=image,name=ghcr.io/flyteorg/flytekit:3ADTed3jxN2hwtMwkTdzmA..,push=true
v0.10.6: Pulling from moby/buildkit
59bf1c3509f3: Pulling fs layer
is this said that, the image spec builed is not based on ghcr.io/flyteorg/flytekit:py3.9-latest?tall-lock-23197
full-evening-87657
11/24/2023, 8:50 AMpyflyte register workflows/image_spec.py
...
#20 [internal] pip install pandas numpy
#20 0.807 Requirement already satisfied: pandas in /usr/local/lib/python3.9/site-packages (1.5.3)
#20 0.807 Requirement already satisfied: numpy in /usr/local/lib/python3.9/site-packages (1.25.2)
#20 0.817 Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.9/site-packages (from pandas) (2023.3.post1)
#20 0.818 Requirement already satisfied: python-dateutil>=2.8.1 in /usr/local/lib/python3.9/site-packages (from pandas) (2.8.2)
#20 0.821 Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.9/site-packages (from python-dateutil>=2.8.1->pandas) (1.16.0)
#20 1.883 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: <https://pip.pypa.io/warnings/venv>
#20 2.272
#20 2.272 [notice] A new release of pip is available: 23.0.1 -> 23.3.1
#20 2.272 [notice] To update, run: pip install --upgrade pip
#20 DONE 2.4s
#21 exporting to image
#21 exporting layers
#21 exporting layers 15.2s done
#21 exporting manifest sha256:e47006a8cfd5d790a089109259d3ccf3d695e85a0fffde9a61b934bc9c7b16c7 0.0s done
#21 exporting config sha256:0cbb93768cd2fe79458ce0062b1ef75a77dcbf89ab80a75fd404410482eb554f 0.0s done
#21 pushing layers
#21 pushing layers 0.5s done
#21 ERROR: failed to authorize: failed to fetch anonymous token: unexpected status from GET request to <https://ghcr.io/token?scope=repository%3Aflyteorg%2Fflytekit%3Apull%2Cpush&service=ghcr.io>: 403 Forbidden
------
> exporting to image:
------
Failed with Unknown Exception <class 'Exception'> Reason: failed to run command envd build --path /tmp/flyte-y7ebo1dt/sandbox/local_flytekit/438ade51efebce7fa3bce718b2423956 --platform linux/amd64 --output type=image,name=<http://ghcr.io/flyteorg/flytekit:3ADTed3jxN2hwtMwkTdzmA..,push=true|ghcr.io/flyteorg/flytekit:3ADTed3jxN2hwtMwkTdzmA..,push=true> with error b'error: failed to fetch anonymous token: unexpected status from GET request to <https://ghcr.io/token?scope=repository%3Aflyteorg%2Fflytekit%3Apull%2Cpush&service=ghcr.io>: 403 Forbidden\n'
failed to run command envd build --path /tmp/flyte-y7ebo1dt/sandbox/local_flytekit/438ade51efebce7fa3bce718b2423956 --platform linux/amd64 --output type=image,name=<http://ghcr.io/flyteorg/flytekit:3ADTed3jxN2hwtMwkTdzmA..,push=true|ghcr.io/flyteorg/flytekit:3ADTed3jxN2hwtMwkTdzmA..,push=true> with error b'error: failed to fetch anonymous token: unexpected status from GET request to <https://ghcr.io/token?scope=repository%3Aflyteorg%2Fflytekit%3Apull%2Cpush&service=ghcr.io>: 403 Forbidden\n'
full-evening-87657
11/24/2023, 8:50 AMfull-evening-87657
11/24/2023, 8:50 AMtoken: unexpected status from GET request to <https://ghcr.io/token?scope=repository%3Aflyteorg%2Fflytekit%3Apull%2Cpush&service=ghcr.io>: 403 Forbidden
\tall-lock-23197
full-evening-87657
11/24/2023, 2:03 PMtall-lock-23197
full-evening-87657
11/24/2023, 2:05 PMtall-lock-23197
full-evening-87657
11/24/2023, 2:07 PMfull-evening-87657
11/29/2023, 1:24 AM...
=> ERROR exporting to image 13.2s
=> => exporting layers 13.2s
=> => exporting manifest sha256:72967fb714481b0392254090e1be0395b64ba5e8cfb153aecb0e99a151c347a6 0.0s
=> => exporting config sha256:5b14d4f75d9eff196c3a8dc2fb8580f32556f67e92d92706af373905f6b354f7 0.0s
=> => pushing layers 0.0s
------
> exporting to image:
------
error: failed to do request: Head "<http://localhost:30000/v2/flytekit/blobs/sha256:5b14d4f75d9eff196c3a8dc2fb8580f32556f67e92d92706af373905f6b354f7>": dial tcp 127.0.0.1:30000: connect: connection refused
Here is the content of above link
{
"errors": [
{
"code": "BLOB_UNKNOWN",
"message": "blob unknown to registry",
"detail": "sha256:5b14d4f75d9eff196c3a8dc2fb8580f32556f67e92d92706af373905f6b354f7"
}
]
}
---------
Here is my image spec
pandas_image_spec = ImageSpec(
base_image="<http://ghcr.io/flyteorg/flytekit:py3.8-1.6.2|ghcr.io/flyteorg/flytekit:py3.8-1.6.2>",
packages=["pandas", "numpy"],
python_version="3.9",
apt_packages=["git"],
env={"Debug": "True"},
registry="localhost:30000",
)
full-evening-87657
11/29/2023, 1:25 AMtall-lock-23197
full-evening-87657
11/29/2023, 9:08 AMfull-evening-87657
11/29/2023, 9:09 AMtall-lock-23197
envd context create --name flyte-sandbox --builder tcp --builder-address localhost:30003 --use
full-evening-87657
11/29/2023, 1:59 PMtall-lock-23197
full-evening-87657
11/29/2023, 5:03 PM