I've been setting up my Metaflow dev environment a...
# ask-metaflow
b
I've been setting up my Metaflow dev environment and ran the unit test suite. Found 8 failing tests in `test_kubernetes.py`related to
validate_kube_labels
looks like the function isn't raising
KubernetesException
at the right level. Is this a known issue or worth a PR?
g
I got a similar error when I was working on an issue
I think it might be happening because two different
KubernetesException
classes exist in the codebase
@boundless-author-34124 can you share the error you are getting?
b
message has been deleted
Here is the log :
g
I got a similar error: platform darwin -- Python 3.13.4, pytest-9.0.2, pluggy-1.6.0 cachedir: .pytest_cache test/unit/test_kubernetes.py::test_kubernetes_decorator_validate_kube_labels_fail[labels0] FAILED [100%] ================================================ FAILURES ================================================ ______________________ test_kubernetes_decorator_validate_kube_labels_fail[labels0] ______________________ labels = {'label': 'a-'} @pytest.mark.parametrize( "labels", [ {"label": "a-"}, {"label": ".a"}, {"label": "test()"}, { "label": ( "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234567890" "1234" ) }, {"label": "(){}??"}, {"valid": "test", "invalid": "bißchen"}, ], ) def test_kubernetes_decorator_validate_kube_labels_fail(labels): """Fail if label contains invalid characters or is too long""" with pytest.raises(KubernetesException):
validate_kube_labels(labels)
test/unit/test_kubernetes.py72 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ metaflow/plugins/kubernetes/kube_utils.py91 in validate_kube_labels return all([validate_label(v) for v in labels.values()]) if labels else True ^^^^^^^^^^^^^^^^^ def validate_label(s: Optional[str]): regex_match = r"^(([A-Za-z0-9][-A-Za-z0-9_.]{0,61})?[A-Za-z0-9])?$" if not s: # allow empty label return True if not re.search(regex_match, s):
raise KubernetesException(
'Invalid value: "%s"\n' "A valid label must be an empty string or one that\n" " - Consist of alphanumeric, '-', '_' or '.' characters\n" " - Begins and ends with an alphanumeric character\n" " - Is at most 63 characters" % s ) E metaflow.plugins.kubernetes.kube_utils.KubernetesException: Invalid value: "a-" E A valid label must be an empty string or one that E - Consist of alphanumeric, '-', '_' or '.' characters E - Begins and ends with an alphanumeric character E - Is at most 63 characters metaflow/plugins/kubernetes/kube_utils.py82 KubernetesException ============================================ warnings summary ============================================ .venv/lib/python3.13/site-packages/_yaml/__init__.py:18 /Users/luisgonzalez/Documents/code/metaflow_for_cloud_dev/metaflow/.venv/lib/python3.13/site-packages/_yaml/__init__.py18 DeprecationWarning: The _yaml extension module is now located at yaml._yaml and its location is subject to change. To use the LibYAML-based parser and emitter, import from `yaml`:
from yaml import CLoader as Loader, CDumper as Dumper
. warnings.warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ======================================== short test summary info ========================================= FAILED test/unit/test_kubernetes.py::test_kubernetes_decorator_validate_kube_labels_fail[labels0] - metaflow.plugins.kubernetes.kube_utils.KubernetesException: Invalid value: "a-" ====================================== 1 failed, 1 warning in 0.20s ======================================
I am going to create an issue and add you
b
Thanks @glamorous-easter-37147 glad it wasn't just my setup. Happy to review the PR when it's up. Looking forward to contributing more as I dig deeper into the codebase.
🙌 1
@glamorous-easter-37147 My GitHub is kartikloops if you want to add me
g
yes of course, thanks
👍 1