Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

name 'yaml' is not defined #553

Open
kwonmha opened this issue Mar 17, 2021 · 2 comments · May be fixed by #555
Open

name 'yaml' is not defined #553

kwonmha opened this issue Mar 17, 2021 · 2 comments · May be fixed by #555

Comments

@kwonmha
Copy link

kwonmha commented Mar 17, 2021

I'm running notebook- https://github.com/kubeflow/fairing/blob/master/examples/mnist/mnist_e2e_on_prem.ipynb
And on the 4th cell

from kubernetes import client as k8s_client
from kubernetes import config as k8s_config
from kubeflow.fairing.utils import is_running_in_k8s

pv_yaml = f'''
apiVersion: v1
kind: PersistentVolume
metadata:
  name: {pv_name}
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: {nfs_path}
    server: {nfs_server}
'''
pvc_yaml = f'''
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {pvc_name}
  namespace: {my_namespace}
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 10Gi
'''

if is_running_in_k8s():
    k8s_config.load_incluster_config()
else:
    k8s_config.load_kube_config()

k8s_core_api = k8s_client.CoreV1Api()
k8s_core_api.create_persistent_volume(yaml.safe_load(pv_yaml))
k8s_core_api.create_namespaced_persistent_volume_claim(my_namespace, yaml.safe_load(pvc_yaml))

It says

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-10-da6a0e14757a> in <module>
     39 
     40 k8s_core_api = k8s_client.CoreV1Api()
---> 41 k8s_core_api.create_persistent_volume(yaml.safe_load(pv_yaml))
     42 k8s_core_api.create_namespaced_persistent_volume_claim(my_namespace, yaml.safe_load(pvc_yaml))

NameError: name 'yaml' is not defined

What should I do?

Environment:

  • Fairing version: (use python -c "import kubeflow.fairing; print(kubeflow.fairing.__version__)"):
    1.0.2

  • Kubeflow version: (version number can be found at the bottom left corner of the Kubeflow dashboard):
    It says 'version dev_local'

  • Minikube version:
    I used microk8s

  • Kubernetes version: (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"20+", GitVersion:"v1.20.4-34+1ae8c29bbb48f7", GitCommit:"1ae8c29bbb48f7a11f9b522538a707477322b3ab", GitTreeState:"clean", BuildDate:"2021-03-08T09:25:07Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20+", GitVersion:"v1.20.4-34+1ae8c29bbb48f7", GitCommit:"1ae8c29bbb48f7a11f9b522538a707477322b3ab", GitTreeState:"clean", BuildDate:"2021-03-08T09:26:35Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}
  • OS (e.g. from /etc/os-release):
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"

NOTE: If you are using fair from master, please provide us the git commit hash.

@kwonmha
Copy link
Author

kwonmha commented Mar 25, 2021

You need to add
import yaml on the cell.

kwonmha added a commit to kwonmha/fairing that referenced this issue Mar 25, 2021
@kwonmha
Copy link
Author

kwonmha commented Mar 25, 2021

And also msrestazure library is needed to run the notebook.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant