Skip to content

Commit b79b917

Browse files
committed
Update job model to be used with workflows
1 parent c8e0bf6 commit b79b917

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

jupyter_scheduler/executors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from jupyter_scheduler.orm import Job, Workflow, create_session
2020
from jupyter_scheduler.parameterize import add_parameters
2121
from jupyter_scheduler.utils import get_utc_timestamp
22-
from jupyter_scheduler.workflows import DescribeTask, DescribeWorkflow
22+
from jupyter_scheduler.workflows import DescribeWorkflow
2323

2424

2525
class ExecutionManager(ABC):

jupyter_scheduler/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __str__(self) -> str:
4242

4343

4444
class Status(str, Enum):
45+
DRAFT = "DRAFT"
4546
CREATED = "CREATED"
4647
QUEUED = "QUEUED"
4748
IN_PROGRESS = "IN_PROGRESS"
@@ -86,6 +87,8 @@ class CreateJob(BaseModel):
8687
output_filename_template: Optional[str] = OUTPUT_FILENAME_TEMPLATE
8788
compute_type: Optional[str] = None
8889
package_input_folder: Optional[bool] = None
90+
depends_on: Optional[str] = None
91+
workflow_id: str = None
8992

9093
@root_validator
9194
def compute_input_filename(cls, values) -> Dict:
@@ -148,6 +151,8 @@ class DescribeJob(BaseModel):
148151
downloaded: bool = False
149152
package_input_folder: Optional[bool] = None
150153
packaged_files: Optional[List[str]] = []
154+
depends_on: Optional[str] = None
155+
workflow_id: str = None
151156

152157
class Config:
153158
orm_mode = True
@@ -193,6 +198,7 @@ class UpdateJob(BaseModel):
193198
status: Optional[Status] = None
194199
name: Optional[str] = None
195200
compute_type: Optional[str] = None
201+
depends_on: Optional[str] = None
196202

197203

198204
class DeleteJob(BaseModel):

jupyter_scheduler/orm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class Job(CommonColumns, Base):
103103
url = Column(String(256), default=generate_jobs_url)
104104
pid = Column(Integer)
105105
idempotency_token = Column(String(256))
106+
depends_on = Column(JsonType(1024))
107+
workflow_id = Column(String(36))
106108
# All new columns added to this table must be nullable to ensure compatibility during database migrations.
107109
# Any default values specified for new columns will be ignored during the migration process.
108110

@@ -112,7 +114,7 @@ class Workflow(Base):
112114
__table_args__ = {"extend_existing": True}
113115
workflow_id = Column(String(36), primary_key=True, default=generate_uuid)
114116
tasks = Column(JsonType(1024))
115-
status = Column(String(64), default=Status.STOPPED)
117+
status = Column(String(64), default=Status.DRAFT)
116118
# All new columns added to this table must be nullable to ensure compatibility during database migrations.
117119
# Any default values specified for new columns will be ignored during the migration process.
118120

jupyter_scheduler/workflows.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ class Config:
5757
orm_mode = True
5858

5959

60-
class DescribeTask(BaseModel):
61-
dependsOn: List[str] = []
62-
status: Status = Status.CREATED
60+
class UpdateWorkflow(BaseModel):
61+
workflow_id: str
62+
tasks: List[str] = None
63+
status: Status = None
6364

6465
class Config:
6566
orm_mode = True

src/handler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ export namespace Scheduler {
372372
timezone?: string;
373373
active?: boolean;
374374
input_uri?: string;
375+
depends_on?: string[];
375376
}
376377

377378
export interface IDescribeJobDefinition {
@@ -418,6 +419,8 @@ export namespace Scheduler {
418419
output_formats?: string[];
419420
compute_type?: string;
420421
package_input_folder?: boolean;
422+
depends_on?: string[];
423+
workflow_id?: string;
421424
}
422425

423426
export interface ICreateJobFromDefinition {
@@ -467,6 +470,8 @@ export namespace Scheduler {
467470
end_time?: number;
468471
downloaded: boolean;
469472
package_input_folder?: boolean;
473+
depends_on?: string[];
474+
workflow_id?: string;
470475
}
471476

472477
export interface ICreateJobResponse {

src/model.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export interface ICreateJobModel
100100
// Is the create button disabled due to a submission in progress?
101101
createInProgress?: boolean;
102102
packageInputFolder?: boolean;
103+
dependsOn?: string[];
104+
workflowId?: string;
103105
}
104106

105107
export const defaultScheduleFields: ModelWithScheduleFields = {
@@ -312,6 +314,8 @@ export interface IJobDetailModel {
312314
job_files: Scheduler.IJobFile[];
313315
downloaded: boolean;
314316
packageInputFolder?: boolean;
317+
dependsOn?: string[];
318+
workflowId?: string;
315319
}
316320

317321
export interface IJobDefinitionModel {
@@ -388,7 +392,9 @@ export function convertDescribeJobtoJobDetail(
388392
startTime: describeJob.start_time,
389393
endTime: describeJob.end_time,
390394
downloaded: describeJob.downloaded,
391-
packageInputFolder: describeJob.package_input_folder
395+
packageInputFolder: describeJob.package_input_folder,
396+
dependsOn: describeJob.depends_on,
397+
workflowId: describeJob.workflow_id
392398
};
393399
}
394400

0 commit comments

Comments
 (0)