feat!: major change of name and adding jenkinsfile, etc.
This commit is contained in:
81
Jenkinsfile
vendored
Normal file
81
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
pipeline {
|
||||
agent {
|
||||
kubernetes {
|
||||
label 'kalpaa' // all your pods will be named with this prefix, followed by a unique id
|
||||
idleMinutes 5 // how long the pod will live after no jobs have run on it
|
||||
yamlFile 'jenkins/ci-agent-pod.yaml' // path to the pod definition relative to the root of our project
|
||||
defaultContainer 'poetry' // define a default container if more than a few stages use it, will default to jnlp container
|
||||
}
|
||||
}
|
||||
|
||||
options {
|
||||
parallelsAlwaysFailFast()
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
echo 'Building...'
|
||||
sh 'python --version'
|
||||
sh 'poetry --version'
|
||||
sh 'poetry install'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
parallel{
|
||||
stage('pytest') {
|
||||
steps {
|
||||
sh 'poetry run pytest'
|
||||
}
|
||||
}
|
||||
stage('lint') {
|
||||
steps {
|
||||
sh 'poetry run flake8 kalpaa tests'
|
||||
}
|
||||
}
|
||||
stage('mypy') {
|
||||
steps {
|
||||
sh 'poetry run mypy kalpaa'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy') {
|
||||
environment {
|
||||
PYPI=credentials("pypi-kalpaa")
|
||||
}
|
||||
|
||||
when {
|
||||
buildingTag()
|
||||
}
|
||||
steps {
|
||||
echo 'Deploying...'
|
||||
sh 'poetry publish -u ${PYPI_USR} -p ${PYPI_PSW} --build'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'This will always run'
|
||||
junit 'pytest.xml'
|
||||
cobertura coberturaReportFile: 'coverage.xml'
|
||||
mail (bcc: '',
|
||||
body: "Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> Build URL: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: 'jenkins@jenkins.deepak.science', mimeType: 'text/html', replyTo: 'dmallubhotla+jenkins@gmail.com', subject: "${env.JOB_NAME} #${env.BUILD_NUMBER}: Build ${currentBuild.currentResult}", to: "dmallubhotla+ci@gmail.com")
|
||||
}
|
||||
success {
|
||||
echo 'This will run only if successful'
|
||||
}
|
||||
failure {
|
||||
echo 'This will run only if failed'
|
||||
}
|
||||
unstable {
|
||||
echo 'This will run only if the run was marked as unstable'
|
||||
}
|
||||
changed {
|
||||
echo 'This will run only if the state of the Pipeline has changed'
|
||||
echo 'For example, if the Pipeline was previously failing but is now successful'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
#
|
||||
# kalpaa
|
||||
|
||||
Need to have a dots.json, indexes.json, the other jsons get generated.
|
||||
|
||||
|
||||
# soucres of truth
|
||||
# sources of truth
|
||||
dots.json
|
||||
indexes.json
|
||||
|
||||
|
||||
34
justfile
34
justfile
@@ -17,22 +17,22 @@ checknix:
|
||||
echo "Using poetry as runner, no nix detected."
|
||||
fi
|
||||
|
||||
# # run all tests
|
||||
# test: fmt
|
||||
# #!/usr/bin/env bash
|
||||
# set -euxo pipefail
|
||||
# run all tests
|
||||
test: fmt
|
||||
#!/usr/bin/env bash
|
||||
set -euxo pipefail
|
||||
|
||||
# if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
|
||||
# echo "testing, using nix..."
|
||||
# flake8 deepdog tests
|
||||
# mypy deepdog
|
||||
# pytest
|
||||
# else
|
||||
# echo "testing..."
|
||||
# poetry run flake8 deepdog tests
|
||||
# poetry run mypy deepdog
|
||||
# poetry run pytest
|
||||
# fi
|
||||
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
|
||||
echo "testing, using nix..."
|
||||
flake8 kalpaa tests
|
||||
mypy kalpaa
|
||||
pytest
|
||||
else
|
||||
echo "testing..."
|
||||
poetry run flake8 kalpaa tests
|
||||
poetry run mypy kalpaa
|
||||
poetry run pytest
|
||||
fi
|
||||
|
||||
# format code
|
||||
fmt:
|
||||
@@ -43,9 +43,9 @@ fmt:
|
||||
else
|
||||
poetry run black .
|
||||
fi
|
||||
find kalpa -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
|
||||
find kalpaa -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
|
||||
# find bin -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
|
||||
# find tests -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
|
||||
find tests -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
|
||||
|
||||
# release the app, checking that our working tree is clean and ready for release, optionally takes target version
|
||||
# release version="":
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
from kalpa.inference_coalesce.coalescer import Coalescer
|
||||
|
||||
__all__ = ["Coalescer"]
|
||||
15
kalpa/__init__.py → kalpaa/__init__.py
Executable file → Normal file
15
kalpa/__init__.py → kalpaa/__init__.py
Executable file → Normal file
@@ -1,6 +1,9 @@
|
||||
from kalpa.read_bin_csv import read_dots_and_binned
|
||||
from kalpa.common import get_model
|
||||
from kalpa.config import (
|
||||
import logging
|
||||
from kalpaa.meta import __version__
|
||||
|
||||
from kalpaa.read_bin_csv import read_dots_and_binned
|
||||
from kalpaa.common import get_model
|
||||
from kalpaa.config import (
|
||||
Config,
|
||||
TantriConfig,
|
||||
GeneralConfig,
|
||||
@@ -10,7 +13,11 @@ from kalpa.config import (
|
||||
MeasurementTypeEnum,
|
||||
)
|
||||
|
||||
def get_version() -> str:
|
||||
return __version__
|
||||
|
||||
__all__ = [
|
||||
"get_version",
|
||||
"read_dots_and_binned",
|
||||
"get_model",
|
||||
"Config",
|
||||
@@ -21,3 +28,5 @@ __all__ = [
|
||||
"ReducedModelParams",
|
||||
"MeasurementTypeEnum",
|
||||
]
|
||||
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
6
kalpa/common/__init__.py → kalpaa/common/__init__.py
Executable file → Normal file
6
kalpa/common/__init__.py → kalpaa/common/__init__.py
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
from kalpa.common.model_params import get_model
|
||||
from kalpa.common.cli_utils import set_up_logging
|
||||
from kalpa.common.runner_utils import (
|
||||
from kalpaa.common.model_params import get_model
|
||||
from kalpaa.common.cli_utils import set_up_logging
|
||||
from kalpaa.common.runner_utils import (
|
||||
new_cd,
|
||||
tantri_binned_output_name,
|
||||
tantri_full_output_name,
|
||||
4
kalpa/common/cli_utils.py → kalpaa/common/cli_utils.py
Executable file → Normal file
4
kalpa/common/cli_utils.py → kalpaa/common/cli_utils.py
Executable file → Normal file
@@ -1,11 +1,11 @@
|
||||
import pathlib
|
||||
import logging
|
||||
import kalpa.config
|
||||
import kalpaa.config
|
||||
import typing
|
||||
|
||||
|
||||
def set_up_logging(
|
||||
config: kalpa.config.Config,
|
||||
config: kalpaa.config.Config,
|
||||
log_file: typing.Optional[str],
|
||||
create_logfile_parents: bool = True,
|
||||
):
|
||||
4
kalpa/common/model_params.py → kalpaa/common/model_params.py
Executable file → Normal file
4
kalpa/common/model_params.py → kalpaa/common/model_params.py
Executable file → Normal file
@@ -2,7 +2,7 @@ import dataclasses
|
||||
import typing
|
||||
import logging
|
||||
from tantri.dipoles.types import Orientation
|
||||
import kalpa.config
|
||||
import kalpaa.config
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -51,7 +51,7 @@ def _fixed_z_model_func(
|
||||
)
|
||||
|
||||
|
||||
def get_model(params: kalpa.config.ReducedModelParams):
|
||||
def get_model(params: kalpaa.config.ReducedModelParams):
|
||||
model_funcs = {
|
||||
Orientation.Z: _fixed_z_model_func,
|
||||
Orientation.RANDOM: LogSpacedRandomCountMultipleDipoleFixedMagnitudeModel,
|
||||
0
kalpa/common/runner_utils.py → kalpaa/common/runner_utils.py
Executable file → Normal file
0
kalpa/common/runner_utils.py → kalpaa/common/runner_utils.py
Executable file → Normal file
3
kalpaa/inference_coalesce/__init__.py
Normal file
3
kalpaa/inference_coalesce/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from kalpaa.inference_coalesce.coalescer import Coalescer
|
||||
|
||||
__all__ = ["Coalescer"]
|
||||
0
kalpa/inference_coalesce/coalescer.py → kalpaa/inference_coalesce/coalescer.py
Executable file → Normal file
0
kalpa/inference_coalesce/coalescer.py → kalpaa/inference_coalesce/coalescer.py
Executable file → Normal file
3
kalpaa/meta.py
Normal file
3
kalpaa/meta.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from importlib.metadata import version
|
||||
|
||||
__version__ = version("kalpa")
|
||||
0
kalpa/read_bin_csv.py → kalpaa/read_bin_csv.py
Executable file → Normal file
0
kalpa/read_bin_csv.py → kalpaa/read_bin_csv.py
Executable file → Normal file
46
kalpa/stages/__init__.py → kalpaa/stages/__init__.py
Executable file → Normal file
46
kalpa/stages/__init__.py → kalpaa/stages/__init__.py
Executable file → Normal file
@@ -1,13 +1,13 @@
|
||||
import pathlib
|
||||
import logging
|
||||
|
||||
import kalpa.stages.stage01
|
||||
import kalpa.stages.stage02
|
||||
import kalpa.stages.stage03
|
||||
import kalpa.stages.stage04
|
||||
import kalpa.common
|
||||
import kalpaa.stages.stage01
|
||||
import kalpaa.stages.stage02
|
||||
import kalpaa.stages.stage03
|
||||
import kalpaa.stages.stage04
|
||||
import kalpaa.common
|
||||
import tantri.dipoles.types
|
||||
import kalpa.config
|
||||
import kalpaa.config
|
||||
|
||||
import argparse
|
||||
|
||||
@@ -18,7 +18,7 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Runner:
|
||||
def __init__(self, config: kalpa.Config):
|
||||
def __init__(self, config: kalpaa.Config):
|
||||
self.config = config
|
||||
_logger.info(f"Initialising runner with {config=}")
|
||||
|
||||
@@ -26,10 +26,10 @@ class Runner:
|
||||
|
||||
if self.config.general_config.skip_to_stage is not None:
|
||||
|
||||
stage01 = kalpa.stages.stage01.Stage01Runner(self.config)
|
||||
stage02 = kalpa.stages.stage02.Stage02Runner(self.config)
|
||||
stage03 = kalpa.stages.stage03.Stage03Runner(self.config)
|
||||
stage04 = kalpa.stages.stage04.Stage04Runner(self.config)
|
||||
stage01 = kalpaa.stages.stage01.Stage01Runner(self.config)
|
||||
stage02 = kalpaa.stages.stage02.Stage02Runner(self.config)
|
||||
stage03 = kalpaa.stages.stage03.Stage03Runner(self.config)
|
||||
stage04 = kalpaa.stages.stage04.Stage04Runner(self.config)
|
||||
|
||||
stages = [stage01, stage02, stage03, stage04]
|
||||
|
||||
@@ -43,19 +43,19 @@ class Runner:
|
||||
# standard run, can keep old
|
||||
|
||||
_logger.info("*** Beginning Stage 01 ***")
|
||||
stage01 = kalpa.stages.stage01.Stage01Runner(self.config)
|
||||
stage01 = kalpaa.stages.stage01.Stage01Runner(self.config)
|
||||
stage01.run()
|
||||
|
||||
_logger.info("*** Beginning Stage 02 ***")
|
||||
stage02 = kalpa.stages.stage02.Stage02Runner(self.config)
|
||||
stage02 = kalpaa.stages.stage02.Stage02Runner(self.config)
|
||||
stage02.run()
|
||||
|
||||
_logger.info("*** Beginning Stage 03 ***")
|
||||
stage03 = kalpa.stages.stage03.Stage03Runner(self.config)
|
||||
stage03 = kalpaa.stages.stage03.Stage03Runner(self.config)
|
||||
stage03.run()
|
||||
|
||||
_logger.info("*** Beginning Stage 04 ***")
|
||||
stage04 = kalpa.stages.stage04.Stage04Runner(self.config)
|
||||
stage04 = kalpaa.stages.stage04.Stage04Runner(self.config)
|
||||
stage04.run()
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ def main():
|
||||
args = parse_args()
|
||||
|
||||
tantri_configs = [
|
||||
kalpa.TantriConfig(123456, 50, 0.5, 100000),
|
||||
kalpaa.TantriConfig(123456, 50, 0.5, 100000),
|
||||
# kalpa.TantriConfig(1234, 50, 0.0005, 10000),
|
||||
]
|
||||
|
||||
@@ -117,7 +117,7 @@ def main():
|
||||
],
|
||||
}
|
||||
|
||||
generation_config = kalpa.GenerationConfig(
|
||||
generation_config = kalpaa.GenerationConfig(
|
||||
tantri_configs=tantri_configs,
|
||||
counts=[3, 31],
|
||||
num_replicas=5,
|
||||
@@ -137,32 +137,32 @@ def main():
|
||||
if args.skip_to_stage not in [1, 2, 3, 4]:
|
||||
raise ValueError(f"There is no stage {args.skip_to_stage}")
|
||||
else:
|
||||
skip = kalpa.config.SkipToStage(args.skip_to_stage - 1)
|
||||
skip = kalpaa.config.SkipToStage(args.skip_to_stage - 1)
|
||||
else:
|
||||
skip = None
|
||||
|
||||
general_config = kalpa.GeneralConfig(
|
||||
measurement_type=kalpa.MeasurementTypeEnum.POTENTIAL,
|
||||
general_config = kalpaa.GeneralConfig(
|
||||
measurement_type=kalpaa.MeasurementTypeEnum.POTENTIAL,
|
||||
out_dir_name=str(root / "out"),
|
||||
skip_to_stage=skip,
|
||||
)
|
||||
|
||||
# kalpa.GeneralConfig
|
||||
|
||||
deepdog_config = kalpa.DeepdogConfig(
|
||||
deepdog_config = kalpaa.DeepdogConfig(
|
||||
costs_to_try=[2, 1],
|
||||
max_monte_carlo_cycles_steps=20,
|
||||
target_success=200,
|
||||
use_log_noise=True,
|
||||
)
|
||||
|
||||
config = kalpa.Config(
|
||||
config = kalpaa.Config(
|
||||
generation_config=generation_config,
|
||||
general_config=general_config,
|
||||
deepdog_config=deepdog_config,
|
||||
)
|
||||
|
||||
kalpa.common.set_up_logging(config, str(root / f"logs/{root}.log"))
|
||||
kalpaa.common.set_up_logging(config, str(root / f"logs/{root}.log"))
|
||||
|
||||
_logger.info(f"Got {config=}")
|
||||
runner = Runner(config)
|
||||
26
kalpa/stages/stage01.py → kalpaa/stages/stage01.py
Executable file → Normal file
26
kalpa/stages/stage01.py → kalpaa/stages/stage01.py
Executable file → Normal file
@@ -4,8 +4,8 @@ import json
|
||||
import pathlib
|
||||
import argparse
|
||||
import logging
|
||||
import kalpa
|
||||
import kalpa.common
|
||||
import kalpaa
|
||||
import kalpaa.common
|
||||
import tantri.cli
|
||||
import tantri.cli.input_files
|
||||
import tantri.cli.input_files.write_dipoles
|
||||
@@ -81,7 +81,7 @@ _logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Stage01Runner:
|
||||
def __init__(self, config: kalpa.Config):
|
||||
def __init__(self, config: kalpaa.Config):
|
||||
self.config = config
|
||||
_logger.info(f"Initialising Stage01 runner with {config=}")
|
||||
|
||||
@@ -103,7 +103,7 @@ class Stage01Runner:
|
||||
dipoles_json = directory / "dipoles.json"
|
||||
|
||||
with open(config_json, "w") as conf_file:
|
||||
params = kalpa.ReducedModelParams(
|
||||
params = kalpaa.ReducedModelParams(
|
||||
count=count, orientation=tantri.dipoles.types.Orientation(orientation)
|
||||
)
|
||||
_logger.debug(f"Got params {params=}")
|
||||
@@ -116,8 +116,8 @@ class Stage01Runner:
|
||||
for tantri_index, tantri_config in enumerate(
|
||||
self.config.generation_config.tantri_configs
|
||||
):
|
||||
output_csv = directory / kalpa.common.tantri_full_output_name(tantri_index)
|
||||
binned_csv = directory / kalpa.common.tantri_binned_output_name(
|
||||
output_csv = directory / kalpaa.common.tantri_full_output_name(tantri_index)
|
||||
binned_csv = directory / kalpaa.common.tantri_binned_output_name(
|
||||
tantri_index
|
||||
)
|
||||
tantri.cli._write_apsd(
|
||||
@@ -189,8 +189,8 @@ class Stage01Runner:
|
||||
for tantri_index, tantri_config in enumerate(
|
||||
self.config.generation_config.tantri_configs
|
||||
):
|
||||
output_csv = directory / kalpa.common.tantri_full_output_name(tantri_index)
|
||||
binned_csv = directory / kalpa.common.tantri_binned_output_name(
|
||||
output_csv = directory / kalpaa.common.tantri_full_output_name(tantri_index)
|
||||
binned_csv = directory / kalpaa.common.tantri_binned_output_name(
|
||||
tantri_index
|
||||
)
|
||||
tantri.cli._write_apsd(
|
||||
@@ -281,19 +281,19 @@ def main():
|
||||
args = parse_args()
|
||||
|
||||
tantri_configs = [
|
||||
kalpa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
kalpaa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpaa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
]
|
||||
generation_config = kalpa.GenerationConfig(
|
||||
generation_config = kalpaa.GenerationConfig(
|
||||
tantri_configs=tantri_configs,
|
||||
counts=[1],
|
||||
num_replicas=3,
|
||||
orientations=[tantri.dipoles.types.Orientation.Z],
|
||||
)
|
||||
|
||||
config = kalpa.Config(generation_config=generation_config)
|
||||
config = kalpaa.Config(generation_config=generation_config)
|
||||
|
||||
kalpa.common.set_up_logging(config, args.log_file)
|
||||
kalpaa.common.set_up_logging(config, args.log_file)
|
||||
|
||||
_logger.info("Generating our data, for the following iterations")
|
||||
|
||||
26
kalpa/stages/stage02.py → kalpaa/stages/stage02.py
Executable file → Normal file
26
kalpa/stages/stage02.py → kalpaa/stages/stage02.py
Executable file → Normal file
@@ -30,8 +30,8 @@ import json
|
||||
#
|
||||
#
|
||||
# folder in curr dir
|
||||
import kalpa
|
||||
import kalpa.common
|
||||
import kalpaa
|
||||
import kalpaa.common
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -74,7 +74,7 @@ def enumify_orientation_string(
|
||||
|
||||
|
||||
class Stage02Runner:
|
||||
def __init__(self, config: kalpa.Config):
|
||||
def __init__(self, config: kalpaa.Config):
|
||||
self.config = config
|
||||
_logger.info(f"Initialising Stage02 runner with {config=}")
|
||||
|
||||
@@ -106,7 +106,7 @@ class Stage02Runner:
|
||||
return ["dot1", "dot2", current_dot]
|
||||
|
||||
def run_in_subdir(self, subdir: pathlib.Path):
|
||||
with kalpa.common.new_cd(subdir):
|
||||
with kalpaa.common.new_cd(subdir):
|
||||
_logger.debug(f"Running inside {subdir=}")
|
||||
|
||||
# TODO hardcoding that we're executing every job index.
|
||||
@@ -153,10 +153,10 @@ class Stage02Runner:
|
||||
)
|
||||
num_tantri_configs = len(self.config.generation_config.tantri_configs)
|
||||
binned_datas = [
|
||||
kalpa.read_dots_and_binned(
|
||||
kalpaa.read_dots_and_binned(
|
||||
self.config.get_dots_json_path(),
|
||||
pathlib.Path("..")
|
||||
/ kalpa.common.tantri_binned_output_name(tantri_index),
|
||||
/ kalpaa.common.tantri_binned_output_name(tantri_index),
|
||||
)
|
||||
for tantri_index in range(num_tantri_configs)
|
||||
]
|
||||
@@ -192,11 +192,11 @@ class Stage02Runner:
|
||||
|
||||
mccount, mccountcycles = occupancies_dict[avg_filled]
|
||||
|
||||
model_params = kalpa.ReducedModelParams(
|
||||
model_params = kalpaa.ReducedModelParams(
|
||||
count=avg_filled, log_magnitude=log_magnitude, orientation=orientation
|
||||
)
|
||||
|
||||
models.append(kalpa.get_model(model_params))
|
||||
models.append(kalpaa.get_model(model_params))
|
||||
|
||||
_logger.info(f"have {len(models)} models to look at")
|
||||
if len(models) == 1:
|
||||
@@ -268,14 +268,14 @@ def main():
|
||||
args = parse_args()
|
||||
|
||||
tantri_configs = [
|
||||
kalpa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
kalpaa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpaa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
]
|
||||
generation_config = kalpa.GenerationConfig(tantri_configs=tantri_configs)
|
||||
generation_config = kalpaa.GenerationConfig(tantri_configs=tantri_configs)
|
||||
|
||||
config = kalpa.Config(generation_config=generation_config)
|
||||
config = kalpaa.Config(generation_config=generation_config)
|
||||
|
||||
kalpa.common.set_up_logging(config, args.log_file)
|
||||
kalpaa.common.set_up_logging(config, args.log_file)
|
||||
|
||||
_logger.info("Generating our data, for the following iterations")
|
||||
|
||||
28
kalpa/stages/stage03.py → kalpaa/stages/stage03.py
Executable file → Normal file
28
kalpa/stages/stage03.py → kalpaa/stages/stage03.py
Executable file → Normal file
@@ -15,8 +15,8 @@ import logging
|
||||
# # import itertools
|
||||
import pdme
|
||||
|
||||
import kalpa.stages
|
||||
import kalpa.stages.stage03_1
|
||||
import kalpaa.stages
|
||||
import kalpaa.stages.stage03_1
|
||||
import tantri.cli
|
||||
import tantri.cli.file_importer
|
||||
import tantri.dipoles.types
|
||||
@@ -25,8 +25,8 @@ import tantri.dipoles.types
|
||||
#
|
||||
#
|
||||
# folder in curr dir
|
||||
import kalpa
|
||||
import kalpa.common
|
||||
import kalpaa
|
||||
import kalpaa.common
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -70,7 +70,7 @@ def read_coalesced_csv(parent_path: pathlib.Path, dot_name: str, target_cost):
|
||||
|
||||
|
||||
class Stage03Runner:
|
||||
def __init__(self, config: kalpa.Config):
|
||||
def __init__(self, config: kalpaa.Config):
|
||||
self.config = config
|
||||
_logger.info(f"Initialising Stage03 runner with {config=}")
|
||||
|
||||
@@ -85,7 +85,7 @@ class Stage03Runner:
|
||||
_logger.info(f"Got dots {self.dots=}")
|
||||
|
||||
def merge_coalesceds(self, sorted_dir: pathlib.Path):
|
||||
out_path = sorted_dir / kalpa.common.merged_coalesced_name()
|
||||
out_path = sorted_dir / kalpaa.common.merged_coalesced_name()
|
||||
with out_path.open("w", newline="") as outfile:
|
||||
writer = csv.DictWriter(outfile, OUT_FIELDNAMES)
|
||||
writer.writeheader()
|
||||
@@ -100,15 +100,15 @@ class Stage03Runner:
|
||||
"""
|
||||
Subdir passed in should be e.g. <>/out/z-10-1/
|
||||
"""
|
||||
with kalpa.common.new_cd(subdir):
|
||||
with kalpaa.common.new_cd(subdir):
|
||||
|
||||
_logger.debug(f"Running inside {subdir=}")
|
||||
|
||||
kalpa.stages.stage03_1.move_all_in_dipoles(subdir / "dipoles")
|
||||
kalpaa.stages.stage03_1.move_all_in_dipoles(subdir / "dipoles")
|
||||
|
||||
seed_index = 0
|
||||
|
||||
sorted_dir = pathlib.Path(kalpa.common.sorted_bayesruns_name())
|
||||
sorted_dir = pathlib.Path(kalpaa.common.sorted_bayesruns_name())
|
||||
_logger.info(f"{sorted_dir.resolve()}")
|
||||
|
||||
for cost in self.config.deepdog_config.costs_to_try:
|
||||
@@ -170,19 +170,19 @@ def main():
|
||||
args = parse_args()
|
||||
|
||||
tantri_configs = [
|
||||
kalpa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
kalpaa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpaa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
]
|
||||
generation_config = kalpa.GenerationConfig(
|
||||
generation_config = kalpaa.GenerationConfig(
|
||||
tantri_configs=tantri_configs,
|
||||
counts=[1],
|
||||
num_replicas=3,
|
||||
orientations=[tantri.dipoles.types.Orientation.Z],
|
||||
)
|
||||
|
||||
config = kalpa.Config(generation_config=generation_config)
|
||||
config = kalpaa.Config(generation_config=generation_config)
|
||||
|
||||
kalpa.common.set_up_logging(config, args.log_file)
|
||||
kalpaa.common.set_up_logging(config, args.log_file)
|
||||
|
||||
_logger.info("Generating our data, for the following iterations")
|
||||
|
||||
6
kalpa/stages/stage03_1.py → kalpaa/stages/stage03_1.py
Executable file → Normal file
6
kalpa/stages/stage03_1.py → kalpaa/stages/stage03_1.py
Executable file → Normal file
@@ -1,4 +1,4 @@
|
||||
import kalpa.common
|
||||
import kalpaa.common
|
||||
import os
|
||||
import logging
|
||||
import argparse
|
||||
@@ -27,7 +27,7 @@ def target_dir(filename) -> BFile:
|
||||
raise ValueError(f"Could not parse {filename=}")
|
||||
tag = parsed_slug["tag"]
|
||||
cost = parsed_slug["target_cost"]
|
||||
target_dirname = f"{kalpa.common.sorted_bayesruns_name()}/{tag}-{cost}"
|
||||
target_dirname = f"{kalpaa.common.sorted_bayesruns_name()}/{tag}-{cost}"
|
||||
file = fileresult.path
|
||||
|
||||
bfile = BFile(file=file, target_dirname=target_dirname)
|
||||
@@ -49,7 +49,7 @@ def move_all_in_dipoles(dipoles_path: pathlib.Path):
|
||||
|
||||
_logger.info(f"Going to try to move files in {dipoles_path=}")
|
||||
|
||||
sorted_dir = pathlib.Path(kalpa.common.sorted_bayesruns_name())
|
||||
sorted_dir = pathlib.Path(kalpaa.common.sorted_bayesruns_name())
|
||||
sorted_dir.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
bayesruns = [
|
||||
28
kalpa/stages/stage04.py → kalpaa/stages/stage04.py
Executable file → Normal file
28
kalpa/stages/stage04.py → kalpaa/stages/stage04.py
Executable file → Normal file
@@ -2,9 +2,9 @@ import typing
|
||||
import logging
|
||||
import argparse
|
||||
import csv
|
||||
import kalpa
|
||||
import kalpa.common
|
||||
import kalpa.inference_coalesce
|
||||
import kalpaa
|
||||
import kalpaa.common
|
||||
import kalpaa.inference_coalesce
|
||||
import tantri.dipoles.types
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -93,7 +93,7 @@ def is_actual(row, actual_normal_orientation, actual_count):
|
||||
|
||||
|
||||
class Stage04Runner:
|
||||
def __init__(self, config: kalpa.Config):
|
||||
def __init__(self, config: kalpaa.Config):
|
||||
self.config = config
|
||||
_logger.info(f"Initialising Stage04 runner with {config=}")
|
||||
|
||||
@@ -104,8 +104,8 @@ class Stage04Runner:
|
||||
subdir_path = self.config.get_out_dir_path() / subdir_name
|
||||
csv_path = (
|
||||
subdir_path
|
||||
/ kalpa.common.sorted_bayesruns_name()
|
||||
/ kalpa.common.merged_coalesced_name()
|
||||
/ kalpaa.common.sorted_bayesruns_name()
|
||||
/ kalpaa.common.merged_coalesced_name()
|
||||
)
|
||||
_logger.debug(f"Reading {csv_path=}")
|
||||
with csv_path.open(mode="r", newline="") as csvfile:
|
||||
@@ -126,8 +126,8 @@ class Stage04Runner:
|
||||
subdir_path = self.config.get_out_dir_path() / subdir_name
|
||||
csv_path = (
|
||||
subdir_path
|
||||
/ kalpa.common.sorted_bayesruns_name()
|
||||
/ kalpa.common.merged_coalesced_name()
|
||||
/ kalpaa.common.sorted_bayesruns_name()
|
||||
/ kalpaa.common.merged_coalesced_name()
|
||||
)
|
||||
_logger.debug(f"Reading {csv_path=}")
|
||||
with csv_path.open(mode="r", newline="") as csvfile:
|
||||
@@ -191,7 +191,7 @@ class Stage04Runner:
|
||||
megamerged_reader = csv.DictReader(infile)
|
||||
rows = [row for row in megamerged_reader]
|
||||
_logger.debug(rows[0])
|
||||
coalescer = kalpa.inference_coalesce.Coalescer(
|
||||
coalescer = kalpaa.inference_coalesce.Coalescer(
|
||||
rows, num_replicas=self.config.generation_config.num_replicas
|
||||
)
|
||||
_logger.info(coalescer.actual_dict.keys())
|
||||
@@ -240,19 +240,19 @@ def main():
|
||||
args = parse_args()
|
||||
|
||||
tantri_configs = [
|
||||
kalpa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
kalpaa.TantriConfig(31415, 100, 5, 100000),
|
||||
kalpaa.TantriConfig(314, 100, 0.00005, 100000),
|
||||
]
|
||||
generation_config = kalpa.GenerationConfig(
|
||||
generation_config = kalpaa.GenerationConfig(
|
||||
tantri_configs=tantri_configs,
|
||||
counts=[1],
|
||||
num_replicas=3,
|
||||
orientations=[tantri.dipoles.types.Orientation.Z],
|
||||
)
|
||||
|
||||
config = kalpa.Config(generation_config=generation_config)
|
||||
config = kalpaa.Config(generation_config=generation_config)
|
||||
|
||||
kalpa.common.set_up_logging(config, args.log_file)
|
||||
kalpaa.common.set_up_logging(config, args.log_file)
|
||||
|
||||
_logger.info("Generating our data, for the following iterations")
|
||||
|
||||
0
kalpaa/tests/__init__.py
Normal file
0
kalpaa/tests/__init__.py
Normal file
6
kalpaa/tests/test_deepdog.py
Normal file
6
kalpaa/tests/test_deepdog.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from kalpaa import __version__
|
||||
import kalpaa
|
||||
|
||||
|
||||
def test_version():
|
||||
assert kalpaa.get_version() == __version__
|
||||
@@ -1,5 +1,5 @@
|
||||
[tool.poetry]
|
||||
name = "kalpa"
|
||||
name = "kalpaa"
|
||||
version = "0.0.1"
|
||||
description = "Groups up and runs full run."
|
||||
authors = ["Deepak Mallubhotla <dmallubhotla+github@gmail.com>"]
|
||||
@@ -21,8 +21,8 @@ requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
stage01 = "kalpa.stages.stage01:main"
|
||||
stage02 = "kalpa.stages.stage02:main"
|
||||
stage03 = "kalpa.stages.stage03:main"
|
||||
stage04 = "kalpa.stages.stage04:main"
|
||||
kalpa = "kalpa.stages:main"
|
||||
stage01 = "kalpaa.stages.stage01:main"
|
||||
stage02 = "kalpaa.stages.stage02:main"
|
||||
stage03 = "kalpaa.stages.stage03:main"
|
||||
stage04 = "kalpaa.stages.stage04:main"
|
||||
kalpaa = "kalpaa.stages:main"
|
||||
|
||||
52
scripts/release.sh
Normal file
52
scripts/release.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
branch_name=$(git symbolic-ref -q HEAD)
|
||||
branch_name=${branch_name##refs/heads/}
|
||||
branch_name=${branch_name:-HEAD}
|
||||
if [ $branch_name != "master" ]; then
|
||||
echo "The current branch is not master!"
|
||||
echo "I'd feel uncomfortable releasing from here..."
|
||||
exit 3
|
||||
fi
|
||||
|
||||
release_needed=false
|
||||
if \
|
||||
{ git log "$( git describe --tags --abbrev=0 )..HEAD" --format='%s' | cut -d: -f1 | sort -u | sed -e 's/([^)]*)//' | grep -q -i -E '^feat|fix|perf|refactor|revert$' ; } || \
|
||||
{ git log "$( git describe --tags --abbrev=0 )..HEAD" --format='%s' | cut -d: -f1 | sort -u | sed -e 's/([^)]*)//' | grep -q -E '\!$' ; } || \
|
||||
{ git log "$( git describe --tags --abbrev=0 )..HEAD" --format='%b' | grep -q -E '^BREAKING CHANGE:' ; }
|
||||
then
|
||||
release_needed=true
|
||||
fi
|
||||
|
||||
if ! [ "$release_needed" = true ]; then
|
||||
echo "No release needed..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
std_version_args=()
|
||||
if [[ -n "${1:-}" ]]; then
|
||||
std_version_args+=( "--release-as" "$1" )
|
||||
echo "Parameter $1 was supplied, so we should use release-as"
|
||||
else
|
||||
echo "No release-as parameter specifed."
|
||||
fi
|
||||
# Working directory clean
|
||||
echo "Doing a dry run..."
|
||||
npx standard-version --dry-run "${std_version_args[@]}"
|
||||
read -p "Does that look good? [y/N] " -n 1 -r
|
||||
echo # (optional) move to a new line
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
# do dangerous stuff
|
||||
npx standard-version "${std_version_args[@]}"
|
||||
git push --follow-tags origin master
|
||||
else
|
||||
echo "okay, never mind then..."
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
echo "Can't create release, working tree unclean..."
|
||||
exit 1
|
||||
fi
|
||||
11
scripts/standard-version/pyproject-updater.js
Normal file
11
scripts/standard-version/pyproject-updater.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const pattern = /(\[tool\.poetry\]\nname = "kalpaa"\nversion = ")(?<vers>\d+\.\d+\.\d+)(")/mg;
|
||||
|
||||
module.exports.readVersion = function (contents) {
|
||||
const result = pattern.exec(contents);
|
||||
return result.groups.vers;
|
||||
}
|
||||
|
||||
module.exports.writeVersion = function (contents, version) {
|
||||
const newContents = contents.replace(pattern, `$1${version}$3`);
|
||||
return newContents;
|
||||
}
|
||||
Reference in New Issue
Block a user