From 79082b767752c6c125968615d3b3eddaf7bdde2c Mon Sep 17 00:00:00 2001 From: Andrii Ieroshenko Date: Wed, 9 Aug 2023 10:45:45 -0700 Subject: [PATCH] updates per @3coins --- jupyter_scheduler/models.py | 12 ++++++------ jupyter_scheduler/orm.py | 4 ++-- jupyter_scheduler/tests/test_scheduler.py | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/jupyter_scheduler/models.py b/jupyter_scheduler/models.py index 112c8203..5b5194e0 100644 --- a/jupyter_scheduler/models.py +++ b/jupyter_scheduler/models.py @@ -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: @@ -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 @@ -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: @@ -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 @@ -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): @@ -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] diff --git a/jupyter_scheduler/orm.py b/jupyter_scheduler/orm.py index 888436cd..efdadbf6 100644 --- a/jupyter_scheduler/orm.py +++ b/jupyter_scheduler/orm.py @@ -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): @@ -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): diff --git a/jupyter_scheduler/tests/test_scheduler.py b/jupyter_scheduler/tests/test_scheduler.py index 65b47a04..60849e49 100644 --- a/jupyter_scheduler/tests/test_scheduler.py +++ b/jupyter_scheduler/tests/test_scheduler.py @@ -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 = { @@ -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 = { @@ -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 = { @@ -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": [], }