Skip to content

Commit bce2e19

Browse files
authored
Merge pull request #564 from avinxshKD/feat/julia-docker-generation
mkconcore: add Julia Docker generation
2 parents bcc693c + 8f10457 commit bce2e19

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

Dockerfile.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM julia:1.10
2+
3+
WORKDIR /src
4+
COPY . .

mkconcore.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,16 @@ def cleanup_script_files():
634634
print(CONCOREPATH+" is not correct path to concore (missing concore_base.py)")
635635
quit()
636636

637+
if 'jl' in required_langs and concoretype=="docker":
638+
try:
639+
fsource = open(CONCOREPATH+"/concoredocker.jl")
640+
except (FileNotFoundError, IOError):
641+
print(CONCOREPATH+" is not correct path to concore (missing concoredocker.jl)")
642+
quit()
643+
with open(outdir+"/src/concore.jl","w") as fcopy:
644+
fcopy.write(fsource.read())
645+
fsource.close()
646+
637647
if 'cpp' in required_langs:
638648
try:
639649
if concoretype=="docker":
@@ -790,6 +800,9 @@ def cleanup_script_files():
790800
if langext=="py":
791801
src_path = CONCOREPATH+"/Dockerfile.py"
792802
logging.info("assuming .py extension for Dockerfile")
803+
elif langext == "jl":
804+
src_path = CONCOREPATH+"/Dockerfile.jl"
805+
logging.info("assuming .jl extension for Dockerfile")
793806
elif langext == "cpp": # 6/22/21
794807
src_path = CONCOREPATH+"/Dockerfile.cpp"
795808
logging.info("assuming .cpp extension for Dockerfile")
@@ -814,6 +827,8 @@ def cleanup_script_files():
814827
fcopy.write(source_content)
815828
if langext=="py":
816829
fcopy.write('CMD ["python", "-i", "'+sourcecode+'"]\n')
830+
if langext=="jl":
831+
fcopy.write('CMD ["julia", "'+sourcecode+'"]\n')
817832
if langext=="m":
818833
fcopy.write('CMD ["octave", "-qf", "--eval", "run('+"'"+sourcecode+"'"+')"]\n') #3/28/21
819834
if langext=="sh":
@@ -837,6 +852,8 @@ def cleanup_script_files():
837852
if langext == "py": #4/29/21
838853
fbuild.write("cp ../src/concore.py .\n")
839854
fbuild.write("cp ../src/concore_base.py .\n")
855+
elif langext == "jl":
856+
fbuild.write("cp ../src/concore.jl .\n")
840857
elif langext == "cpp": #6/22/21
841858
fbuild.write("cp ../src/concore.hpp .\n")
842859
elif langext == "v": #6/25/21

tests/test_cli.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,54 @@ def test_build_command_docker_compose_single_node(self):
391391
metadata = json.loads(Path("out/STUDY.json").read_text())
392392
self.assertIn("docker-compose.yml", metadata["checksums"])
393393

394+
def test_build_command_docker_compose_julia_node(self):
395+
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
396+
result = self.runner.invoke(cli, ["init", "test-project"])
397+
self.assertEqual(result.exit_code, 0)
398+
399+
script_path = Path("test-project/src/script.py")
400+
script_path.rename("test-project/src/script.jl")
401+
Path("test-project/src/script.jl").write_text(
402+
'include("concore.jl")\nusing .Concore\n'
403+
)
404+
405+
workflow_path = Path("test-project/workflow.graphml")
406+
content = workflow_path.read_text()
407+
workflow_path.write_text(content.replace("N1:script.py", "N1:script.jl"))
408+
409+
result = self.runner.invoke(
410+
cli,
411+
[
412+
"build",
413+
"test-project/workflow.graphml",
414+
"--source",
415+
"test-project/src",
416+
"--output",
417+
"out",
418+
"--type",
419+
"docker",
420+
"--compose",
421+
],
422+
)
423+
self.assertEqual(result.exit_code, 0)
424+
425+
docker_runtime = Path(__file__).resolve().parents[1] / "concoredocker.jl"
426+
self.assertEqual(
427+
Path("out/src/concore.jl").read_text(), docker_runtime.read_text()
428+
)
429+
430+
dockerfile = Path("out/src/Dockerfile.script").read_text()
431+
self.assertIn("FROM julia:1.10", dockerfile)
432+
self.assertIn('CMD ["julia", "script.jl"]', dockerfile)
433+
434+
build_script = Path("out/build").read_text()
435+
self.assertIn("cp ../src/script.jl .", build_script)
436+
self.assertIn("cp ../src/concore.jl .", build_script)
437+
438+
compose_content = Path("out/docker-compose.yml").read_text()
439+
self.assertIn("container_name: 'N1'", compose_content)
440+
self.assertIn("image: 'docker-script'", compose_content)
441+
394442
def test_build_command_docker_compose_multi_node(self):
395443
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
396444
Path("src").mkdir()

0 commit comments

Comments
 (0)