-
Notifications
You must be signed in to change notification settings - Fork 978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: Use Runner enum type instead of string for Job model #651
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
import com.google.protobuf.InvalidProtocolBufferException; | ||
import feast.core.FeatureSetProto; | ||
import feast.core.IngestionJobProto; | ||
import feast.core.job.Runner; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.persistence.CascadeType; | ||
|
@@ -55,9 +56,9 @@ public class Job extends AbstractTimestampEntity { | |
private String extId; | ||
|
||
// Runner type | ||
// Use Runner.name() when converting a Runner to string to assign to this property. | ||
@Enumerated(EnumType.STRING) | ||
@Column(name = "runner") | ||
private String runner; | ||
private Runner runner; | ||
Comment on lines
-58
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removed comment sums up the motivation of the PR. |
||
|
||
// Source id | ||
@ManyToOne | ||
|
@@ -96,7 +97,7 @@ public Job() { | |
public Job( | ||
String id, | ||
String extId, | ||
String runner, | ||
Runner runner, | ||
Source source, | ||
Store sink, | ||
List<FeatureSet> featureSets, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import feast.core.IngestionJobProto; | ||
import feast.core.dao.JobRepository; | ||
import feast.core.job.JobManager; | ||
import feast.core.job.Runner; | ||
import feast.core.log.Action; | ||
import feast.core.log.AuditLogger; | ||
import feast.core.log.Resource; | ||
|
@@ -50,13 +51,13 @@ | |
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
/** Defines a Job Managemenent Service that allows users to manage feast ingestion jobs. */ | ||
/** A Job Management Service that allows users to manage Feast ingestion jobs. */ | ||
@Slf4j | ||
@Service | ||
public class JobService { | ||
private JobRepository jobRepository; | ||
private SpecService specService; | ||
private Map<String, JobManager> jobManagers; | ||
private final JobRepository jobRepository; | ||
private final SpecService specService; | ||
private final Map<Runner, JobManager> jobManagers; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of scope for this PR, but I still feel like JobManager can be changed to something closer to Runner. In fact it can probably be |
||
|
||
@Autowired | ||
public JobService( | ||
|
@@ -66,13 +67,13 @@ public JobService( | |
|
||
this.jobManagers = new HashMap<>(); | ||
for (JobManager manager : jobManagerList) { | ||
this.jobManagers.put(manager.getRunnerType().name(), manager); | ||
this.jobManagers.put(manager.getRunnerType(), manager); | ||
} | ||
} | ||
|
||
/* Job Service API */ | ||
/** | ||
* List Ingestion Jobs in feast matching the given request. See CoreService protobuf documentation | ||
* List Ingestion Jobs in Feast matching the given request. See CoreService protobuf documentation | ||
* for more detailed documentation. | ||
* | ||
* @param request list ingestion jobs request specifying which jobs to include | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright 2018-2020 The Feast Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package feast.core.job; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.util.NoSuchElementException; | ||
import org.junit.Test; | ||
|
||
public class RunnerTest { | ||
|
||
@Test | ||
public void toStringReturnsHumanReadableName() { | ||
assertThat(Runner.DATAFLOW.toString(), is("DataflowRunner")); | ||
} | ||
|
||
@Test | ||
public void fromStringLoadsValueFromHumanReadableName() { | ||
var humanName = Runner.DATAFLOW.toString(); | ||
assertThat(Runner.fromString(humanName), is(Runner.DATAFLOW)); | ||
} | ||
|
||
@Test(expected = NoSuchElementException.class) | ||
public void fromStringThrowsNoSuchElementExceptionForUnknownValue() { | ||
Runner.fromString("this is not a valid Runner"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt this is perhaps a more fitting exception type for this case.