Skip to content

Commit

Permalink
updates per @3coins
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-i committed Aug 9, 2023
1 parent 2ce0232 commit 79082b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions jupyter_scheduler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class CreateJob(BaseModel):
name: str
output_filename_template: Optional[str] = OUTPUT_FILENAME_TEMPLATE
compute_type: Optional[str] = None
triggered_by: Optional[Event] = None
create_event: Optional[Event] = None

@root_validator
def compute_input_filename(cls, values) -> Dict:
Expand Down Expand Up @@ -158,7 +158,7 @@ class DescribeJob(BaseModel):
status: Status = Status.CREATED
status_message: Optional[str] = None
downloaded: bool = False
triggered_by: Optional[Event] = None
create_event: Optional[Event] = None

class Config:
orm_mode = True
Expand Down Expand Up @@ -223,7 +223,7 @@ class CreateJobDefinition(BaseModel):
compute_type: Optional[str] = None
schedule: Optional[str] = None
timezone: Optional[str] = None
on_events: List[EventType] = []
events: List[EventType] = []

@root_validator
def compute_input_filename(cls, values) -> Dict:
Expand All @@ -249,7 +249,7 @@ class DescribeJobDefinition(BaseModel):
create_time: int
update_time: int
active: bool
on_events: List[EventType] = []
events: List[EventType] = []

class Config:
orm_mode = True
Expand All @@ -269,7 +269,7 @@ class UpdateJobDefinition(BaseModel):
active: Optional[bool] = None
compute_type: Optional[str] = None
input_uri: Optional[str] = None
on_events: List[EventType] = []
events: List[EventType] = []


class ListJobDefinitionsQuery(BaseModel):
Expand Down Expand Up @@ -311,4 +311,4 @@ class JobFeature(str, Enum):
class Event(BaseModel):
event_id: str
event_type: str
parameters: Dict[str, str]
parameters: Dict[str, Any]
4 changes: 2 additions & 2 deletions jupyter_scheduler/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Job(CommonColumns, Base):
url = Column(String(256), default=generate_jobs_url)
pid = Column(Integer)
idempotency_token = Column(String(256))
triggered_by = Column(JsonType(1024), nullable=True)
create_event = Column(JsonType(1024), nullable=True)


class JobDefinition(CommonColumns, Base):
Expand All @@ -109,7 +109,7 @@ class JobDefinition(CommonColumns, Base):
url = Column(String(256), default=generate_job_definitions_url)
create_time = Column(Integer, default=get_utc_timestamp)
active = Column(Boolean, default=True)
on_events = Column(JsonType(1024), default=list)
events = Column(JsonType(1024), default=list)


def create_tables(db_url, drop_tables=False):
Expand Down
18 changes: 9 additions & 9 deletions jupyter_scheduler/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ def test_create_job_definition(jp_scheduler):
assert "helloworld.ipynb" == definition.input_filename
assert "default" == definition.runtime_environment_name
assert "hello world" == definition.name
assert [] == definition.on_events
assert [] == definition.events


def test_create_job_definition_with_on_events(jp_scheduler):
params_with_on_events = {
def test_create_job_definition_with_events(jp_scheduler):
params_with_events = {
**test_job_def_params,
"on_events": [EventType(**event_type_params)],
"events": [EventType(**event_type_params)],
}
create_job_definition(jp_scheduler, params_with_on_events)
create_job_definition(jp_scheduler, params_with_events)

with jp_scheduler.db_session() as session:
definitions = session.query(JobDefinition).all()
definition = definitions[0]
assert [{"name": "a", "parameters": {"foo": "bar"}}] == definition.on_events
assert [{"name": "a", "parameters": {"foo": "bar"}}] == definition.events


job_definition_1 = {
Expand All @@ -74,7 +74,7 @@ def test_create_job_definition_with_on_events(jp_scheduler):
"update_time": 1,
"create_time": 1,
"active": True,
"on_events": [],
"events": [],
}

job_definition_2 = {
Expand All @@ -88,7 +88,7 @@ def test_create_job_definition_with_on_events(jp_scheduler):
"create_time": 2,
"active": True,
"tags": ["tag_2"],
"on_events": [],
"events": [],
}

job_definition_3 = {
Expand All @@ -102,7 +102,7 @@ def test_create_job_definition_with_on_events(jp_scheduler):
"create_time": 3,
"active": False,
"tags": ["tag_3"],
"on_events": [],
"events": [],
}


Expand Down

0 comments on commit 79082b7

Please sign in to comment.