Skip to content

Commit 0c4acc0

Browse files
committed
feature gates in jobs + deploy
1 parent a7fdd5b commit 0c4acc0

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

nbox/jobs.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def upload_job_folder(
171171
trigger: bool = False,
172172
deploy: bool = True,
173173
pin: bool = False,
174+
feature_gates: dict = {},
174175

175176
# all the things for resources
176177
resource_cpu: str = "",
@@ -380,6 +381,7 @@ def __common_resource(db: Resource) -> Resource:
380381
init_folder = init_folder,
381382
job_id = job_proto.id,
382383
job_name = job_proto.name,
384+
feature_gates = feature_gates,
383385
dag = DAGProto(),
384386
workspace_id = workspace_id,
385387
schedule = None,
@@ -416,7 +418,7 @@ def __common_resource(db: Resource) -> Resource:
416418
exe_jinja_kwargs = exe_jinja_kwargs,
417419
)
418420
if deploy:
419-
out.deploy()
421+
out.deploy(feature_gates = feature_gates)
420422
if trigger:
421423
out.pin()
422424
else:
@@ -630,14 +632,15 @@ def logs(self, f = sys.stdout):
630632
f.write(log)
631633
f.flush()
632634

633-
def deploy(self, tag: str = ""):
635+
def deploy(self, tag: str = "", feature_gates: Dict[str, str] = {}):
634636
model = ModelProto(
635637
id = self.model_id,
636638
serving_group_id = self.serving_id,
637639
)
638640
if tag:
639641
model.feature_gates.update({
640-
"SetModelMetadata": tag
642+
"SetModelMetadata": tag,
643+
**feature_gates,
641644
})
642645
response: ModelProto = mpb.rpc(
643646
nbox_model_service_stub.Deploy,
@@ -874,14 +877,15 @@ def refresh(self):
874877

875878
self.status = self.job_proto.Status.keys()[self.job_proto.status]
876879

877-
def trigger(self, tag: str = ""):
880+
def trigger(self, tag: str = "", feature_gates: dict = {}):
878881
"""Manually triger this job.
879882
880883
Args:
881884
tag (str, optional): Tag to be set in the run metadata, read in more detail before trying to use this. Defaults to "".
882885
"""
883886
logger.debug(f"Triggering job '{self.job_proto.id}'")
884887
if tag:
888+
self.job_proto.feature_gates.update(feature_gates)
885889
self.job_proto.feature_gates.update({"SetRunMetadata": tag})
886890
mpb.rpc(nbox_grpc_stub.TriggerJob, JobRequest(auth_info=self.auth_info, job = self.job_proto), f"Could not trigger job '{self.job_proto.id}'")
887891
logger.info(f"Triggered job '{self.job_proto.id}'")

nbox/network.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def _upload_serving_zip(zip_path: str, workspace_id: str, serving_id: str, model
209209
def deploy_job(
210210
init_folder: str,
211211
job_name: str,
212+
feature_gates: Dict[str, str],
212213
dag: DAG,
213214
schedule: Schedule,
214215
resource: Resource,
@@ -256,7 +257,8 @@ def deploy_job(
256257
created_at = SimplerTimes.get_now_pb(),
257258
schedule = schedule.get_message() if schedule is not None else None, # JobProto.Schedule(cron = "0 0 24 2 0"),
258259
dag = dag,
259-
resource = resource
260+
resource = resource,
261+
feature_gates = feature_gates,
260262
)
261263
job_proto_fp = U.join(gettempdir(), "job_proto.msg")
262264
mpb.write_binary_to_file(job_proto, job_proto_fp)

nbox/relics/client.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,8 @@ def get_from(self, local_path: str, remote_path: str, unzip: bool = False) -> No
263263
raise ValueError("Relic does not exist, pass create=True")
264264
logger.debug(f"Getting '{local_path}' from '{remote_path}'")
265265

266-
files = self.list_files(remote_path)
267266
file_ = list(filter(
268-
lambda x: x.name == remote_path, files
267+
lambda x: x.name == remote_path, self.ls(remote_path)
269268
))
270269
if not file_:
271270
raise ValueError(f"File {remote_path} does not exist in the relic")

nbox/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.12.5c9"
1+
__version__ = "0.12.5c10"
22
_major, _minor, _patch = __version__.split(".")
33
_major = int(_major)
44
_minor = int(_minor)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "nbox"
3-
version = "0.12.5c9"
3+
version = "0.12.5c10"
44
description = "ML Inference 🥶"
55
authors = [
66
"NBX Research <research@nimblebox.ai>",

0 commit comments

Comments
 (0)