Commit cf42e679 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

add docstrings

parent 99cd7b5a
Pipeline #18633 passed with stage
in 3 minutes and 24 seconds
......@@ -11,6 +11,18 @@ import shutil
def run(cmd, cwd='.', return_stdout=False):
"""Run a system command
cmd : string
Command to run
cwd : string, optional
Working directory to run command from, default is current working directory
return_stdout : bool, optional
If True, the text output to stdout is return\n
If False (default), the text is written on the screen
print("%s> %s" % (cwd, cmd), flush=True)
cwd = Path(cwd).resolve()
if cwd.is_file():
......@@ -44,6 +56,16 @@ def run(cmd, cwd='.', return_stdout=False):
def clone(url, branch='master', depth=""):
"""Clone repository
url : string
Url of repository to clone
branch : string, optional
Branch of repository to clone, default is master
depth : int or ""
Number of revisions to clone, default is all
folder = Path(os.path.splitext(os.path.basename(url))[0])
if depth:
depth = "--depth %d" % depth
......@@ -59,6 +81,7 @@ def clone(url, branch='master', depth=""):
def clone_hawc2binary(platform='win32'):
"""Clone HAWC2 binaries, platform can be 'win32','win64','linux'"""
p = f'hawc2-{platform}'
clone("" % p, depth=1)
return Path("./%s/" % p)
# -*- coding: utf-8 -*-
"""Prepare the zip file for the model
import os
import shutil
from refutils.htc_conversion import base_to_hs2, base_to_step, base_to_turb, base_to_test
......@@ -10,6 +8,8 @@ from wetb.hawc2 import HTCFile
class ReferenceModel():
"""Class for collecting dlls, generate htc-input files and test the model"""
def __init__(self, model_path_name, htc_basename, model_kwargs, dll_list,
step=True, turb=True, hs2=True, test=True):
......@@ -24,6 +24,7 @@ class ReferenceModel():
self.test = test
def prepare_model(self):
"""Collect dlls, generate htc-input files and save working-model zip file"""
# get ref name
......@@ -61,9 +62,9 @@ class ReferenceModel():
control_dir = mod_dir + 'control/' # must end with slash!
# delete dlls in control repo
try: # if control folder exists, delete dlls
except FileNotFoundError: # if control folder doesn't exist, create it
if os.path.isdir(control_dir):
run('git clean -f', cwd=control_dir)
# ======= get dlls from binary repo =======
......@@ -94,7 +95,8 @@ class ReferenceModel():
# ======= make the archive =======
shutil.make_archive(zip_name, 'zip', mod_dir)
def test_model(self):
def test_with_hawc2binary_master(self):
"""Clone HAWC2-Binary and run test simulation. Exception is raise if simulation do not succeed"""
if not os.path.isfile(f'../{self.model_path_name}/htc/{self.htc_basename}'):
self.test = True
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment