File tree 3 files changed +25
-2
lines changed
tests/resources/sample_project
3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 23
23
from .schedule import Schedule , ScheduleAttempt
24
24
from .session import Session
25
25
from .task import Task
26
- from .util import archive_files , to_iso8601
26
+ from .util import archive_files , to_iso8601 , to_iso_instant
27
27
from .workflow import Workflow
28
28
29
29
logger = logging .getLogger (__name__ )
@@ -193,6 +193,9 @@ def create_project(
193
193
self ,
194
194
project_name : str ,
195
195
target_dir : str ,
196
+ schedule_from : Optional [datetime ],
197
+ clear_schedule : Optional [List [str ]] = None ,
198
+ clear_schedule_all : Optional [bool ] = None ,
196
199
exclude_patterns : Optional [List [str ]] = None ,
197
200
revision : Optional [str ] = None ,
198
201
) -> Project :
@@ -209,6 +212,12 @@ def create_project(
209
212
"""
210
213
revision = revision or str (uuid .uuid4 ())
211
214
params = {"project" : project_name , "revision" : revision }
215
+ if schedule_from :
216
+ params ["schedule_from" ] = to_iso_instant (schedule_from )
217
+ if clear_schedule :
218
+ params ["clear_schedule" ] = clear_schedule
219
+ if clear_schedule_all :
220
+ params ["clear_schedule_all" ] = "true"
212
221
213
222
default_excludes = [
214
223
"venv" ,
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def to_iso8601(dt: Optional[Union[str, datetime]]) -> str:
48
48
if isinstance (dt , datetime ):
49
49
# Naive object
50
50
if not dt .tzinfo :
51
- return dt .astimezone (timezone ( timedelta ( 0 ), "UTC" ) ).isoformat ()
51
+ return dt .astimezone (timezone . utc ).isoformat ()
52
52
# Aware object
53
53
else :
54
54
return dt .isoformat ()
@@ -58,3 +58,15 @@ def to_iso8601(dt: Optional[Union[str, datetime]]) -> str:
58
58
59
59
else :
60
60
raise ValueError ("Unexpected type" )
61
+
62
+
63
+ def to_iso_instant (dt : datetime ) -> str :
64
+ if isinstance (dt , datetime ):
65
+ return (
66
+ dt .astimezone (timezone .utc )
67
+ .isoformat (timespec = "seconds" )
68
+ .replace ("+00:00" , "Z" )
69
+ )
70
+
71
+ else :
72
+ raise ValueError ("Unexpected type" )
Original file line number Diff line number Diff line change
1
+ +hello:
2
+ echo>: hello
You can’t perform that action at this time.
0 commit comments