Skip to content

Commit 4436673

Browse files
authored
feat: Allow hyphen in repo name (#5562)
* allow hyphen in repo nam Signed-off-by: HaoXuAI <[email protected]> * fix unit test Signed-off-by: HaoXuAI <[email protected]> * fix unit test Signed-off-by: HaoXuAI <[email protected]> * fix int test Signed-off-by: HaoXuAI <[email protected]> * fix readme Signed-off-by: HaoXuAI <[email protected]> * fix test Signed-off-by: HaoXuAI <[email protected]> --------- Signed-off-by: HaoXuAI <[email protected]>
1 parent a66d890 commit 4436673

File tree

10 files changed

+21
-19
lines changed

10 files changed

+21
-19
lines changed

infra/feast-operator/api/v1alpha1/featurestore_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const (
6868

6969
// FeatureStoreSpec defines the desired state of FeatureStore
7070
type FeatureStoreSpec struct {
71-
// +kubebuilder:validation:Pattern="^[A-Za-z0-9][A-Za-z0-9_]*$"
72-
// FeastProject is the Feast project id. This can be any alphanumeric string with underscores, but it cannot start with an underscore. Required.
71+
// +kubebuilder:validation:Pattern="^[A-Za-z0-9][A-Za-z0-9_-]*$"
72+
// FeastProject is the Feast project id. This can be any alphanumeric string with underscores and hyphens, but it cannot start with an underscore or hyphen. Required.
7373
FeastProject string `json:"feastProject"`
7474
FeastProjectDir *FeastProjectDir `json:"feastProjectDir,omitempty"`
7575
Services *FeatureStoreServices `json:"services,omitempty"`

infra/feast-operator/bundle/manifests/feast.dev_featurestores.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ spec:
463463
type: object
464464
feastProject:
465465
description: FeastProject is the Feast project id.
466-
pattern: ^[A-Za-z0-9][A-Za-z0-9_]*$
466+
pattern: ^[A-Za-z0-9][A-Za-z0-9_-]*$
467467
type: string
468468
feastProjectDir:
469469
description: FeastProjectDir defines how to create the feast project
@@ -4423,7 +4423,7 @@ spec:
44234423
type: object
44244424
feastProject:
44254425
description: FeastProject is the Feast project id.
4426-
pattern: ^[A-Za-z0-9][A-Za-z0-9_]*$
4426+
pattern: ^[A-Za-z0-9][A-Za-z0-9_-]*$
44274427
type: string
44284428
feastProjectDir:
44294429
description: FeastProjectDir defines how to create the feast project

infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ spec:
463463
type: object
464464
feastProject:
465465
description: FeastProject is the Feast project id.
466-
pattern: ^[A-Za-z0-9][A-Za-z0-9_]*$
466+
pattern: ^[A-Za-z0-9][A-Za-z0-9_-]*$
467467
type: string
468468
feastProjectDir:
469469
description: FeastProjectDir defines how to create the feast project
@@ -4423,7 +4423,7 @@ spec:
44234423
type: object
44244424
feastProject:
44254425
description: FeastProject is the Feast project id.
4426-
pattern: ^[A-Za-z0-9][A-Za-z0-9_]*$
4426+
pattern: ^[A-Za-z0-9][A-Za-z0-9_-]*$
44274427
type: string
44284428
feastProjectDir:
44294429
description: FeastProjectDir defines how to create the feast project

infra/feast-operator/dist/install.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ spec:
471471
type: object
472472
feastProject:
473473
description: FeastProject is the Feast project id.
474-
pattern: ^[A-Za-z0-9][A-Za-z0-9_]*$
474+
pattern: ^[A-Za-z0-9][A-Za-z0-9_-]*$
475475
type: string
476476
feastProjectDir:
477477
description: FeastProjectDir defines how to create the feast project
@@ -4431,7 +4431,7 @@ spec:
44314431
type: object
44324432
feastProject:
44334433
description: FeastProject is the Feast project id.
4434-
pattern: ^[A-Za-z0-9][A-Za-z0-9_]*$
4434+
pattern: ^[A-Za-z0-9][A-Za-z0-9_-]*$
44354435
type: string
44364436
feastProjectDir:
44374437
description: FeastProjectDir defines how to create the feast project

infra/feast-operator/docs/api/markdown/ref.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ _Appears in:_
218218

219219
| Field | Description |
220220
| --- | --- |
221-
| `feastProject` _string_ | FeastProject is the Feast project id. This can be any alphanumeric string with underscores, but it cannot start with an underscore. Required. |
221+
| `feastProject` _string_ | FeastProject is the Feast project id. This can be any alphanumeric string with underscores and hyphens, but it cannot start with an underscore or hyphen. Required. |
222222
| `feastProjectDir` _[FeastProjectDir](#feastprojectdir)_ | |
223223
| `services` _[FeatureStoreServices](#featurestoreservices)_ | |
224224
| `authz` _[AuthzConfig](#authzconfig)_ | |

sdk/python/feast/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def is_valid(self):
117117
if not is_valid_name(self.name):
118118
raise ValueError(
119119
f"Project name, {self.name}, should only have "
120-
f"alphanumerical values and underscores but not start with an underscore."
120+
f"alphanumerical values, underscores, and hyphens but not start with an underscore or hyphen."
121121
)
122122

123123
@classmethod

sdk/python/feast/repo_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def _validate_project_name(cls, v: str) -> str:
485485
if not is_valid_name(v):
486486
raise ValueError(
487487
f"Project name, {v}, should only have "
488-
f"alphanumerical values and underscores but not start with an underscore."
488+
f"alphanumerical values, underscores, and hyphens but not start with an underscore or hyphen."
489489
)
490490
return v
491491

sdk/python/feast/repo_operations.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def apply_total(repo_config: RepoConfig, repo_path: Path, skip_source_validation
396396
if not is_valid_name(project.name):
397397
print(
398398
f"{project.name} is not valid. Project name should only have "
399-
f"alphanumerical values and underscores but not start with an underscore."
399+
f"alphanumerical values, underscores, and hyphens but not start with an underscore or hyphen."
400400
)
401401
sys.exit(1)
402402
# TODO: When we support multiple projects in a single repo, we should filter repo contents by project. Currently there is no way to associate Feast objects to project.
@@ -445,7 +445,7 @@ def init_repo(repo_name: str, template: str):
445445

446446
if not is_valid_name(repo_name):
447447
raise BadParameter(
448-
message="Name should be alphanumeric values and underscores but not start with an underscore",
448+
message="Name should be alphanumeric values, underscores, and hyphens but not start with an underscore or hyphen",
449449
param_hint="PROJECT_DIRECTORY",
450450
)
451451
repo_path = Path(os.path.join(Path.cwd(), repo_name))
@@ -506,8 +506,10 @@ def init_repo(repo_name: str, template: str):
506506

507507

508508
def is_valid_name(name: str) -> bool:
509-
"""A name should be alphanumeric values and underscores but not start with an underscore"""
510-
return not name.startswith("_") and re.compile(r"\W+").search(name) is None
509+
"""A name should be alphanumeric values, underscores, and hyphens but not start with an underscore"""
510+
return (
511+
not name.startswith(("_", "-")) and re.compile(r"[^\w-]+").search(name) is None
512+
)
511513

512514

513515
def generate_project_name() -> str:

sdk/python/tests/unit/infra/scaffolding/test_repo_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ def test_invalid_project_name():
169169
_test_config(
170170
dedent(
171171
"""
172-
project: foo-1
172+
project: -foo
173173
registry: "registry.db"
174174
provider: local
175175
"""
176176
),
177-
expect_error="alphanumerical values ",
177+
expect_error="alphanumerical values, underscores, and hyphens ",
178178
)
179179

180180
_test_config(
@@ -185,7 +185,7 @@ def test_invalid_project_name():
185185
provider: local
186186
"""
187187
),
188-
expect_error="alphanumerical values ",
188+
expect_error="alphanumerical values, underscores, and hyphens ",
189189
)
190190

191191

sdk/python/tests/unit/test_repo_operations_validate_feast_project_name.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ def test_is_valid_name():
1111
("invalid_name_", True),
1212
("12345678901234567", True),
1313
("too_long_name_123", True),
14+
("hyphen-name", True),
1415
# Invalid project name cases
1516
("_invalidName", False),
16-
("invalid-Name", False),
1717
("invalid name", False),
1818
("invalid@name", False),
1919
("invalid$name", False),

0 commit comments

Comments
 (0)