1212from traitlets import Bool
1313from traitlets import Callable as TCallable
1414from traitlets import Dict as TDict
15+ from traitlets import Enum as TEnum
1516from traitlets import Int as TInt
1617from traitlets import List as TList
17- from traitlets import Unicode , Enum as TEnum
18+ from traitlets import Unicode
1819from traitlets import Union as TUnion
1920from traitlets import default
2021
@@ -334,6 +335,13 @@ def service_name(self) -> str:
334335 return f"{ self .job_name } "
335336 raise ValueError ("notebook_id is not set" )
336337
338+ job_template_path = Unicode (
339+ help = """
340+ The path to the job template file with jinja2 placeholders
341+ see templates/job.hcl.j2
342+ """
343+ ).tag (config = True )
344+
337345 async def start (self ):
338346 nomad_service_config = build_nomad_config_from_options (self )
339347 nomad_httpx_client = build_nomad_httpx_client (nomad_service_config )
@@ -363,8 +371,9 @@ async def start(self):
363371 elif self .vault_policies :
364372 policies = self .vault_policies
365373
374+ self .log .info ("scheduling job %s" , self .job_name )
366375 job_hcl = create_job (
367- JobData (
376+ job_data = JobData (
368377 job_name = self .job_name ,
369378 username = self .user .name ,
370379 notebook_name = self .name ,
@@ -377,7 +386,8 @@ async def start(self):
377386 memory = self .user_options ["memory" ],
378387 volume_data = volume_data ,
379388 policies = policies ,
380- )
389+ ),
390+ job_template_path = self .job_template_path ,
381391 )
382392
383393 await nomad_service .schedule_job (job_hcl )
@@ -470,9 +480,6 @@ async def address_and_port_from_nomad(
470480 self .log .info ("Getting service %s from nomad" , self .service_name )
471481 return await nomad_service .get_service_address (self .job_name )
472482
473-
474-
475-
476483 async def poll (self ):
477484 nomad_httpx_client = build_nomad_httpx_client (
478485 build_nomad_config_from_options (self )
0 commit comments