Skip to content

Commit 71bb81e

Browse files
committed
Add software ABC
1 parent 3788727 commit 71bb81e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import worker
2+
3+
from abc import ABC, abstractproperty
4+
from dataclasses import dataclass
5+
from pathlib import Path
6+
7+
8+
@dataclass
9+
class Program(ABC):
10+
version: str
11+
location: Path
12+
13+
@abstractproperty
14+
def install_command(self) -> str:
15+
pass
16+
17+
@abstractproperty
18+
def executable(self) -> Path:
19+
pass
20+
21+
def __post_init__(self):
22+
self.installation = self.install()
23+
24+
def install(self) -> str:
25+
command = f"""
26+
if [ -d "{self.location}" ]; then exit 0; fi
27+
28+
mkdir -p {self.location}
29+
30+
export TEMPORARY_DIRECTORY=$(mktemp -d)
31+
cd $TEMPORARY_DIRECTORY
32+
33+
{self.install_command}
34+
35+
rm -r $TEMPORARY_DIRECTORY
36+
"""
37+
38+
name = type(self).__name__
39+
return worker.execute(command, job_name=f"INSTALL_{name}", vcpu=8, memory=16000)
40+

0 commit comments

Comments
 (0)