Skip to content

Commit

Permalink
Merge pull request #8407 from OpenMined/eelco/fix-job-schema
Browse files Browse the repository at this point in the history
remove job v4, add new schema to job v3
  • Loading branch information
eelcovdw authored Jan 22, 2024
2 parents df8dbd3 + 8d524ae commit 1c71e17
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 48 deletions.
7 changes: 1 addition & 6 deletions packages/syft/src/syft/protocol/protocol_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -978,12 +978,7 @@
"JobItem": {
"3": {
"version": 3,
"hash": "7293ce8bf17bc7420b764bc32fd89512ecbfa045f12db0513904794a6b000581",
"action": "add"
},
"4": {
"version": 4,
"hash": "e6a4e7e37c747e40bcf0567946c28a18e5eda1029287c3738e223ae0cc705622",
"hash": "5b93a59e28574691339d22826d5650969336a2e930b93d6b3fe6d5409ca0cfc4",
"action": "add"
}
},
Expand Down
45 changes: 5 additions & 40 deletions packages/syft/src/syft/service/job/job_stash.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from ...types.syft_object import SYFT_OBJECT_VERSION_1
from ...types.syft_object import SYFT_OBJECT_VERSION_2
from ...types.syft_object import SYFT_OBJECT_VERSION_3
from ...types.syft_object import SYFT_OBJECT_VERSION_4
from ...types.syft_object import SyftObject
from ...types.syft_object import short_uid
from ...types.transforms import drop
Expand Down Expand Up @@ -95,31 +94,10 @@ class JobV2(SyftObject):
job_pid: Optional[int] = None


@serializable()
class JobV3(SyftObject):
__canonical_name__ = "JobItem"
__version__ = SYFT_OBJECT_VERSION_3

id: UID
node_uid: UID
result: Optional[Any]
resolved: bool = False
status: JobStatus = JobStatus.CREATED
log_id: Optional[UID]
parent_job_id: Optional[UID]
n_iters: Optional[int] = 0
current_iter: Optional[int] = None
creation_time: Optional[str] = None
action: Optional[Action] = None
job_pid: Optional[int] = None
job_worker_id: Optional[UID] = None
updated_at: Optional[DateTime] = None


@serializable()
class Job(SyftObject):
__canonical_name__ = "JobItem"
__version__ = SYFT_OBJECT_VERSION_4
__version__ = SYFT_OBJECT_VERSION_3

id: UID
node_uid: UID
Expand Down Expand Up @@ -557,29 +535,16 @@ def from_job(
return info


@migrate(Job, JobV3)
def downgrade_job_v4_to_v3():
return [
drop(["user_code_id"]),
]


@migrate(JobV3, Job)
def upgrade_job_v3_to_v4():
return [
make_set_default("user_code_id", None),
]


@migrate(JobV3, JobV2)
@migrate(Job, JobV2)
def downgrade_job_v3_to_v2():
return [drop(["job_worker_id"])]
return [drop(["job_worker_id", "user_code_id"])]


@migrate(JobV2, JobV3)
@migrate(JobV2, Job)
def upgrade_job_v2_to_v3():
return [
make_set_default("job_worker_id", None),
make_set_default("user_code_id", None),
]


Expand Down
2 changes: 0 additions & 2 deletions packages/syft/src/syft/types/syft_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@
SYFT_OBJECT_VERSION_1 = 1
SYFT_OBJECT_VERSION_2 = 2
SYFT_OBJECT_VERSION_3 = 3
SYFT_OBJECT_VERSION_4 = 4

supported_object_versions = [
SYFT_OBJECT_VERSION_1,
SYFT_OBJECT_VERSION_2,
SYFT_OBJECT_VERSION_3,
SYFT_OBJECT_VERSION_4,
]

HIGHEST_SYFT_OBJECT_VERSION = max(supported_object_versions)
Expand Down

0 comments on commit 1c71e17

Please sign in to comment.