Compare commits
1 Commits
83c2a6d3b0
...
83207b7886
Author | SHA1 | Date | |
---|---|---|---|
83207b7886 |
@ -2,14 +2,6 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
### [0.7.9](https://gitea.deepak.science:2222/physics/deepdog/compare/0.7.8...0.7.9) (2024-04-21)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* adds ability to write custom dmc filters ([ea080ca](https://gitea.deepak.science:2222/physics/deepdog/commit/ea080ca1c7068042ce1e0a222d317f785a6b05f4))
|
|
||||||
* adds tarucha phase calculation, using spin qubit precession rate noise ([3ae0783](https://gitea.deepak.science:2222/physics/deepdog/commit/3ae0783d00cbe6a76439c1d671f2cff621d8d0a8))
|
|
||||||
|
|
||||||
### [0.7.8](https://gitea.deepak.science:2222/physics/deepdog/compare/0.7.7...0.7.8) (2024-02-29)
|
### [0.7.8](https://gitea.deepak.science:2222/physics/deepdog/compare/0.7.7...0.7.8) (2024-02-29)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
from typing import Sequence
|
|
||||||
from deepdog.direct_monte_carlo.direct_mc import DirectMonteCarloFilter
|
|
||||||
import numpy
|
|
||||||
|
|
||||||
|
|
||||||
class ComposedDMCFilter(DirectMonteCarloFilter):
|
|
||||||
def __init__(self, filters: Sequence[DirectMonteCarloFilter]):
|
|
||||||
self.filters = filters
|
|
||||||
|
|
||||||
def filter_samples(self, samples: numpy.ndarray) -> numpy.ndarray:
|
|
||||||
current_sample = samples
|
|
||||||
for filter in self.filters:
|
|
||||||
current_sample = filter.filter_samples(current_sample)
|
|
||||||
return current_sample
|
|
@ -2,7 +2,7 @@ import pdme.model
|
|||||||
import pdme.measurement
|
import pdme.measurement
|
||||||
import pdme.measurement.input_types
|
import pdme.measurement.input_types
|
||||||
import pdme.subspace_simulation
|
import pdme.subspace_simulation
|
||||||
from typing import Tuple, Dict, NewType, Any
|
from typing import Tuple, Sequence
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import logging
|
import logging
|
||||||
import numpy
|
import numpy
|
||||||
@ -30,20 +30,6 @@ class DirectMonteCarloConfig:
|
|||||||
tag: str = ""
|
tag: str = ""
|
||||||
|
|
||||||
|
|
||||||
# Aliasing dict as a generic data container
|
|
||||||
DirectMonteCarloData = NewType("DirectMonteCarloData", Dict[str, Any])
|
|
||||||
|
|
||||||
|
|
||||||
class DirectMonteCarloFilter:
|
|
||||||
"""
|
|
||||||
Abstract class for filtering out samples matching some criteria. Initialise with data as needed,
|
|
||||||
then filter out samples as needed.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def filter_samples(self, samples: numpy.ndarray) -> numpy.ndarray:
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
|
|
||||||
class DirectMonteCarloRun:
|
class DirectMonteCarloRun:
|
||||||
"""
|
"""
|
||||||
A single model Direct Monte Carlo run, currently implemented only using single threading.
|
A single model Direct Monte Carlo run, currently implemented only using single threading.
|
||||||
@ -79,26 +65,25 @@ class DirectMonteCarloRun:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
model_name_pair: Tuple[str, pdme.model.DipoleModel],
|
model_name_pair: Tuple[str, pdme.model.DipoleModel],
|
||||||
filter: DirectMonteCarloFilter,
|
measurements: Sequence[pdme.measurement.DotRangeMeasurement],
|
||||||
config: DirectMonteCarloConfig,
|
config: DirectMonteCarloConfig,
|
||||||
):
|
):
|
||||||
self.model_name, self.model = model_name_pair
|
self.model_name, self.model = model_name_pair
|
||||||
|
|
||||||
# self.measurements = measurements
|
self.measurements = measurements
|
||||||
# self.dot_inputs = [(measure.r, measure.f) for measure in self.measurements]
|
self.dot_inputs = [(measure.r, measure.f) for measure in self.measurements]
|
||||||
|
|
||||||
# self.dot_inputs_array = pdme.measurement.input_types.dot_inputs_to_array(
|
self.dot_inputs_array = pdme.measurement.input_types.dot_inputs_to_array(
|
||||||
# self.dot_inputs
|
self.dot_inputs
|
||||||
# )
|
)
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.filter = filter
|
(
|
||||||
# (
|
self.lows,
|
||||||
# self.lows,
|
self.highs,
|
||||||
# self.highs,
|
) = pdme.measurement.input_types.dot_range_measurements_low_high_arrays(
|
||||||
# ) = pdme.measurement.input_types.dot_range_measurements_low_high_arrays(
|
self.measurements
|
||||||
# self.measurements
|
)
|
||||||
# )
|
|
||||||
|
|
||||||
def _single_run(self, seed) -> numpy.ndarray:
|
def _single_run(self, seed) -> numpy.ndarray:
|
||||||
rng = numpy.random.default_rng(seed)
|
rng = numpy.random.default_rng(seed)
|
||||||
@ -108,20 +93,18 @@ class DirectMonteCarloRun:
|
|||||||
)
|
)
|
||||||
|
|
||||||
current_sample = sample_dipoles
|
current_sample = sample_dipoles
|
||||||
|
for di, low, high in zip(self.dot_inputs_array, self.lows, self.highs):
|
||||||
|
|
||||||
return self.filter.filter_samples(current_sample)
|
if len(current_sample) < 1:
|
||||||
# for di, low, high in zip(self.dot_inputs_array, self.lows, self.highs):
|
break
|
||||||
|
vals = pdme.util.fast_v_calc.fast_vs_for_dipoleses(
|
||||||
|
numpy.array([di]), current_sample
|
||||||
|
)
|
||||||
|
|
||||||
# if len(current_sample) < 1:
|
current_sample = current_sample[
|
||||||
# break
|
numpy.all((vals > low) & (vals < high), axis=1)
|
||||||
# vals = pdme.util.fast_v_calc.fast_vs_for_dipoleses(
|
]
|
||||||
# numpy.array([di]), current_sample
|
return current_sample
|
||||||
# )
|
|
||||||
|
|
||||||
# current_sample = current_sample[
|
|
||||||
# numpy.all((vals > low) & (vals < high), axis=1)
|
|
||||||
# ]
|
|
||||||
# return current_sample
|
|
||||||
|
|
||||||
def execute(self) -> DirectMonteCarloResult:
|
def execute(self) -> DirectMonteCarloResult:
|
||||||
step_count = 0
|
step_count = 0
|
||||||
|
@ -1,143 +0,0 @@
|
|||||||
from numpy import ndarray
|
|
||||||
from deepdog.direct_monte_carlo.direct_mc import DirectMonteCarloFilter
|
|
||||||
from typing import Sequence
|
|
||||||
import pdme.measurement
|
|
||||||
import pdme.measurement.input_types
|
|
||||||
import pdme.util.fast_nonlocal_spectrum
|
|
||||||
import pdme.util.fast_v_calc
|
|
||||||
import numpy
|
|
||||||
|
|
||||||
|
|
||||||
class SingleDotPotentialFilter(DirectMonteCarloFilter):
|
|
||||||
def __init__(self, measurements: Sequence[pdme.measurement.DotRangeMeasurement]):
|
|
||||||
self.measurements = measurements
|
|
||||||
self.dot_inputs = [(measure.r, measure.f) for measure in self.measurements]
|
|
||||||
|
|
||||||
self.dot_inputs_array = pdme.measurement.input_types.dot_inputs_to_array(
|
|
||||||
self.dot_inputs
|
|
||||||
)
|
|
||||||
(
|
|
||||||
self.lows,
|
|
||||||
self.highs,
|
|
||||||
) = pdme.measurement.input_types.dot_range_measurements_low_high_arrays(
|
|
||||||
self.measurements
|
|
||||||
)
|
|
||||||
|
|
||||||
def filter_samples(self, samples: ndarray) -> ndarray:
|
|
||||||
current_sample = samples
|
|
||||||
for di, low, high in zip(self.dot_inputs_array, self.lows, self.highs):
|
|
||||||
|
|
||||||
if len(current_sample) < 1:
|
|
||||||
break
|
|
||||||
vals = pdme.util.fast_v_calc.fast_vs_for_dipoleses(
|
|
||||||
numpy.array([di]), current_sample
|
|
||||||
)
|
|
||||||
|
|
||||||
current_sample = current_sample[
|
|
||||||
numpy.all((vals > low) & (vals < high), axis=1)
|
|
||||||
]
|
|
||||||
return current_sample
|
|
||||||
|
|
||||||
|
|
||||||
class DoubleDotSpinQubitFrequencyFilter(DirectMonteCarloFilter):
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
pair_phase_measurements: Sequence[pdme.measurement.DotPairRangeMeasurement],
|
|
||||||
):
|
|
||||||
self.pair_phase_measurements = pair_phase_measurements
|
|
||||||
self.dot_pair_inputs = [
|
|
||||||
(measure.r1, measure.r2, measure.f)
|
|
||||||
for measure in self.pair_phase_measurements
|
|
||||||
]
|
|
||||||
self.dot_pair_inputs_array = (
|
|
||||||
pdme.measurement.input_types.dot_pair_inputs_to_array(self.dot_pair_inputs)
|
|
||||||
)
|
|
||||||
(
|
|
||||||
self.pair_phase_lows,
|
|
||||||
self.pair_phase_highs,
|
|
||||||
) = pdme.measurement.input_types.dot_range_measurements_low_high_arrays(
|
|
||||||
self.pair_phase_measurements
|
|
||||||
)
|
|
||||||
|
|
||||||
def fast_s_spin_qubit_tarucha_nonlocal_dipoleses(
|
|
||||||
self, dot_pair_inputs: numpy.ndarray, dipoleses: numpy.ndarray
|
|
||||||
) -> numpy.ndarray:
|
|
||||||
"""
|
|
||||||
No error correction here baby.
|
|
||||||
"""
|
|
||||||
ps = dipoleses[:, :, 0:3]
|
|
||||||
ss = dipoleses[:, :, 3:6]
|
|
||||||
ws = dipoleses[:, :, 6]
|
|
||||||
|
|
||||||
r1s = dot_pair_inputs[:, 0, 0:3]
|
|
||||||
r2s = dot_pair_inputs[:, 1, 0:3]
|
|
||||||
f1s = dot_pair_inputs[:, 0, 3]
|
|
||||||
# Don't actually need this
|
|
||||||
# f2s = dot_pair_inputs[:, 1, 3]
|
|
||||||
|
|
||||||
diffses1 = r1s[:, None] - ss[:, None, :]
|
|
||||||
diffses2 = r2s[:, None] - ss[:, None, :]
|
|
||||||
|
|
||||||
norms1 = numpy.linalg.norm(diffses1, axis=3)
|
|
||||||
norms2 = numpy.linalg.norm(diffses2, axis=3)
|
|
||||||
|
|
||||||
alphses1 = (
|
|
||||||
(
|
|
||||||
3
|
|
||||||
* numpy.transpose(
|
|
||||||
numpy.transpose(
|
|
||||||
numpy.einsum("abcd,acd->abc", diffses1, ps) / (norms1**2)
|
|
||||||
)
|
|
||||||
* numpy.transpose(diffses1)
|
|
||||||
)[:, :, :, 0]
|
|
||||||
)
|
|
||||||
- ps[:, :, 0, numpy.newaxis]
|
|
||||||
) / (norms1**3)
|
|
||||||
alphses2 = (
|
|
||||||
(
|
|
||||||
3
|
|
||||||
* numpy.transpose(
|
|
||||||
numpy.transpose(
|
|
||||||
numpy.einsum("abcd,acd->abc", diffses2, ps) / (norms2**2)
|
|
||||||
)
|
|
||||||
* numpy.transpose(diffses2)
|
|
||||||
)[:, :, :, 0]
|
|
||||||
)
|
|
||||||
- ps[:, :, 0, numpy.newaxis]
|
|
||||||
) / (norms2**3)
|
|
||||||
|
|
||||||
bses = (1 / numpy.pi) * (
|
|
||||||
ws[:, None, :] / (f1s[:, None] ** 2 + ws[:, None, :] ** 2)
|
|
||||||
)
|
|
||||||
|
|
||||||
return numpy.einsum("...j->...", alphses1 * alphses2 * bses)
|
|
||||||
|
|
||||||
def filter_samples(self, samples: ndarray) -> ndarray:
|
|
||||||
current_sample = samples
|
|
||||||
|
|
||||||
for pi, plow, phigh in zip(
|
|
||||||
self.dot_pair_inputs_array, self.pair_phase_lows, self.pair_phase_highs
|
|
||||||
):
|
|
||||||
if len(current_sample) < 1:
|
|
||||||
break
|
|
||||||
|
|
||||||
###
|
|
||||||
# This should be abstracted out, but we're going to dump it here for time pressure's sake
|
|
||||||
###
|
|
||||||
# vals = pdme.util.fast_nonlocal_spectrum.signarg(
|
|
||||||
# pdme.util.fast_nonlocal_spectrum.fast_s_nonlocal_dipoleses(
|
|
||||||
# numpy.array([pi]), current_sample
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
vals = pdme.util.fast_nonlocal_spectrum.signarg(
|
|
||||||
self.fast_s_spin_qubit_tarucha_nonlocal_dipoleses(
|
|
||||||
numpy.array([pi]), current_sample
|
|
||||||
)
|
|
||||||
)
|
|
||||||
current_sample = current_sample[
|
|
||||||
numpy.all(
|
|
||||||
((vals > plow) & (vals < phigh)) | ((vals < plow) & (vals > phigh)),
|
|
||||||
axis=1,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
return current_sample
|
|
@ -66,7 +66,7 @@ def get_a_result_fast_filter_pairs(input) -> int:
|
|||||||
return len(current_sample)
|
return len(current_sample)
|
||||||
|
|
||||||
|
|
||||||
def get_a_result_fast_filter_potential_pair_phase_only(input) -> int:
|
def get_a_result_fast_filter_pair_phase_only(input) -> int:
|
||||||
(
|
(
|
||||||
model,
|
model,
|
||||||
pair_inputs,
|
pair_inputs,
|
||||||
@ -102,103 +102,6 @@ def get_a_result_fast_filter_potential_pair_phase_only(input) -> int:
|
|||||||
return len(current_sample)
|
return len(current_sample)
|
||||||
|
|
||||||
|
|
||||||
def get_a_result_fast_filter_tarucha_spin_qubit_pair_phase_only(input) -> int:
|
|
||||||
(
|
|
||||||
model,
|
|
||||||
pair_inputs,
|
|
||||||
pair_phase_lows,
|
|
||||||
pair_phase_highs,
|
|
||||||
monte_carlo_count,
|
|
||||||
seed,
|
|
||||||
) = input
|
|
||||||
|
|
||||||
def fast_s_spin_qubit_tarucha_nonlocal_dipoleses(
|
|
||||||
dot_pair_inputs: numpy.ndarray, dipoleses: numpy.ndarray
|
|
||||||
) -> numpy.ndarray:
|
|
||||||
"""
|
|
||||||
No error correction here baby.
|
|
||||||
"""
|
|
||||||
ps = dipoleses[:, :, 0:3]
|
|
||||||
ss = dipoleses[:, :, 3:6]
|
|
||||||
ws = dipoleses[:, :, 6]
|
|
||||||
|
|
||||||
r1s = dot_pair_inputs[:, 0, 0:3]
|
|
||||||
r2s = dot_pair_inputs[:, 1, 0:3]
|
|
||||||
f1s = dot_pair_inputs[:, 0, 3]
|
|
||||||
# don't actually need, because we're assuming they're the same frequencies across the pair
|
|
||||||
# f2s = dot_pair_inputs[:, 1, 3]
|
|
||||||
|
|
||||||
diffses1 = r1s[:, None] - ss[:, None, :]
|
|
||||||
diffses2 = r2s[:, None] - ss[:, None, :]
|
|
||||||
|
|
||||||
norms1 = numpy.linalg.norm(diffses1, axis=3)
|
|
||||||
norms2 = numpy.linalg.norm(diffses2, axis=3)
|
|
||||||
|
|
||||||
alphses1 = (
|
|
||||||
(
|
|
||||||
3
|
|
||||||
* numpy.transpose(
|
|
||||||
numpy.transpose(
|
|
||||||
numpy.einsum("abcd,acd->abc", diffses1, ps) / (norms1**2)
|
|
||||||
)
|
|
||||||
* numpy.transpose(diffses1)
|
|
||||||
)[:, :, :, 0]
|
|
||||||
)
|
|
||||||
- ps[:, :, 0, numpy.newaxis]
|
|
||||||
) / (norms1**3)
|
|
||||||
alphses2 = (
|
|
||||||
(
|
|
||||||
3
|
|
||||||
* numpy.transpose(
|
|
||||||
numpy.transpose(
|
|
||||||
numpy.einsum("abcd,acd->abc", diffses2, ps) / (norms2**2)
|
|
||||||
)
|
|
||||||
* numpy.transpose(diffses2)
|
|
||||||
)[:, :, :, 0]
|
|
||||||
)
|
|
||||||
- ps[:, :, 0, numpy.newaxis]
|
|
||||||
) / (norms2**3)
|
|
||||||
|
|
||||||
bses = (1 / numpy.pi) * (
|
|
||||||
ws[:, None, :] / (f1s[:, None] ** 2 + ws[:, None, :] ** 2)
|
|
||||||
)
|
|
||||||
|
|
||||||
return numpy.einsum("...j->...", alphses1 * alphses2 * bses)
|
|
||||||
|
|
||||||
rng = numpy.random.default_rng(seed)
|
|
||||||
# TODO: A long term refactor is to pull the frequency stuff out from here. The None stands for max_frequency, which is unneeded in the actually useful models.
|
|
||||||
sample_dipoles = model.get_monte_carlo_dipole_inputs(
|
|
||||||
monte_carlo_count, None, rng_to_use=rng
|
|
||||||
)
|
|
||||||
|
|
||||||
current_sample = sample_dipoles
|
|
||||||
|
|
||||||
for pi, plow, phigh in zip(pair_inputs, pair_phase_lows, pair_phase_highs):
|
|
||||||
if len(current_sample) < 1:
|
|
||||||
break
|
|
||||||
|
|
||||||
###
|
|
||||||
# This should be abstracted out, but we're going to dump it here for time pressure's sake
|
|
||||||
###
|
|
||||||
# vals = pdme.util.fast_nonlocal_spectrum.signarg(
|
|
||||||
# pdme.util.fast_nonlocal_spectrum.fast_s_nonlocal_dipoleses(
|
|
||||||
# numpy.array([pi]), current_sample
|
|
||||||
# )
|
|
||||||
#
|
|
||||||
vals = pdme.util.fast_nonlocal_spectrum.signarg(
|
|
||||||
fast_s_spin_qubit_tarucha_nonlocal_dipoleses(
|
|
||||||
numpy.array([pi]), current_sample
|
|
||||||
)
|
|
||||||
)
|
|
||||||
current_sample = current_sample[
|
|
||||||
numpy.all(
|
|
||||||
((vals > plow) & (vals < phigh)) | ((vals < plow) & (vals > phigh)),
|
|
||||||
axis=1,
|
|
||||||
)
|
|
||||||
]
|
|
||||||
return len(current_sample)
|
|
||||||
|
|
||||||
|
|
||||||
def get_a_result_fast_filter(input) -> int:
|
def get_a_result_fast_filter(input) -> int:
|
||||||
model, dot_inputs, lows, highs, monte_carlo_count, seed = input
|
model, dot_inputs, lows, highs, monte_carlo_count, seed = input
|
||||||
|
|
||||||
@ -396,7 +299,6 @@ class RealSpectrumRun:
|
|||||||
seeds = seed_sequence.spawn(self.monte_carlo_cycles)
|
seeds = seed_sequence.spawn(self.monte_carlo_cycles)
|
||||||
|
|
||||||
if self.use_pair_measurements:
|
if self.use_pair_measurements:
|
||||||
_logger.debug("using pair measurements")
|
|
||||||
current_success = sum(
|
current_success = sum(
|
||||||
pool.imap_unordered(
|
pool.imap_unordered(
|
||||||
get_a_result_fast_filter_pairs,
|
get_a_result_fast_filter_pairs,
|
||||||
@ -418,11 +320,9 @@ class RealSpectrumRun:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif self.use_pair_phase_measurements:
|
elif self.use_pair_phase_measurements:
|
||||||
_logger.debug("using pair phase measurements")
|
|
||||||
_logger.debug("specifically using tarucha")
|
|
||||||
current_success = sum(
|
current_success = sum(
|
||||||
pool.imap_unordered(
|
pool.imap_unordered(
|
||||||
get_a_result_fast_filter_tarucha_spin_qubit_pair_phase_only,
|
get_a_result_fast_filter_pairs,
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
model,
|
model,
|
||||||
|
38
do.sh
Normal file
38
do.sh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Do - The Simplest Build Tool on Earth.
|
||||||
|
# Documentation and examples see https://github.com/8gears/do
|
||||||
|
|
||||||
|
set -Eeuo pipefail # -e "Automatic exit from bash shell script on error" -u "Treat unset variables and parameters as errors"
|
||||||
|
|
||||||
|
build() {
|
||||||
|
echo "I am ${FUNCNAME[0]}ing"
|
||||||
|
poetry build
|
||||||
|
}
|
||||||
|
|
||||||
|
test() {
|
||||||
|
echo "I am ${FUNCNAME[0]}ing"
|
||||||
|
poetry run flake8 deepdog tests
|
||||||
|
poetry run mypy deepdog
|
||||||
|
poetry run pytest
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt() {
|
||||||
|
poetry run black .
|
||||||
|
find . -not \( -path "./.*" -type d -prune \) -type f -name "*.py" -exec sed -i -e 's/ /\t/g' {} \;
|
||||||
|
}
|
||||||
|
|
||||||
|
release() {
|
||||||
|
./scripts/release.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
htmlcov() {
|
||||||
|
poetry run pytest --cov-report=html
|
||||||
|
}
|
||||||
|
|
||||||
|
all() {
|
||||||
|
build && test
|
||||||
|
}
|
||||||
|
|
||||||
|
"$@" # <- execute the task
|
||||||
|
|
||||||
|
[ "$#" -gt 0 ] || printf "Usage:\n\t./do.sh %s\n" "($(compgen -A function | grep '^[^_]' | paste -sd '|' -))"
|
145
flake.lock
generated
145
flake.lock
generated
@ -1,33 +1,28 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710146030,
|
"lastModified": 1648297722,
|
||||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
|
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_2": {
|
"flake-utils_2": {
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_2"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1705309234,
|
"lastModified": 1653893745,
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -36,34 +31,29 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nix-github-actions": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"poetry2nixSrc",
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1703863825,
|
|
||||||
"narHash": "sha256-rXwqjtwiGKJheXB43ybM8NwWB8rO2dSRrEqes0S7F5Y=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "nix-github-actions",
|
|
||||||
"rev": "5163432afc817cf8bd1f031418d1869e4c9d5547",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "nix-github-actions",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710703777,
|
"lastModified": 1655087213,
|
||||||
"narHash": "sha256-M4CNAgjrtvrxIWIAc98RTYcVFoAgwUhrYekeiMScj18=",
|
"narHash": "sha256-4R5oQ+OwGAAcXWYrxC4gFMTUSstGxaN8kN7e8hkum/8=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fc7885fbcea4b782142e06ce2d4d08cf92862004",
|
"rev": "37b6b161e536fddca54424cf80662bce735bdd1e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "37b6b161e536fddca54424cf80662bce735bdd1e",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1655046959,
|
||||||
|
"narHash": "sha256-gxqHZKq1ReLDe6ZMJSbmSZlLY95DsVq5o6jQihhzvmw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "07bf3d25ce1da3bee6703657e6a787a4c6cdcea9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -72,27 +62,23 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"poetry2nixSrc": {
|
"poetry2nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils_2",
|
"flake-utils": "flake-utils_2",
|
||||||
"nix-github-actions": "nix-github-actions",
|
"nixpkgs": "nixpkgs_2"
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"systems": "systems_3",
|
|
||||||
"treefmt-nix": "treefmt-nix"
|
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1708589824,
|
"lastModified": 1654921554,
|
||||||
"narHash": "sha256-2GOiFTkvs5MtVF65sC78KNVxQSmsxtk0WmV1wJ9V2ck=",
|
"narHash": "sha256-hkfMdQAHSwLWlg0sBVvgrQdIiBP45U1/ktmFpY4g2Mo=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "poetry2nix",
|
"repo": "poetry2nix",
|
||||||
"rev": "3c92540611f42d3fb2d0d084a6c694cd6544b609",
|
"rev": "7b71679fa7df00e1678fc3f1d1d4f5f372341b63",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "poetry2nix",
|
"repo": "poetry2nix",
|
||||||
|
"rev": "7b71679fa7df00e1678fc3f1d1d4f5f372341b63",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -100,72 +86,7 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"poetry2nixSrc": "poetry2nixSrc"
|
"poetry2nix": "poetry2nix"
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_2": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "systems",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"treefmt-nix": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"poetry2nixSrc",
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1708335038,
|
|
||||||
"narHash": "sha256-ETLZNFBVCabo7lJrpjD6cAbnE11eDOjaQnznmg/6hAE=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt-nix",
|
|
||||||
"rev": "e504621290a1fd896631ddbc5e9c16f4366c9f65",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt-nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
83
flake.nix
83
flake.nix
@ -1,46 +1,63 @@
|
|||||||
{
|
{
|
||||||
description = "Application packaged using poetry2nix";
|
description = "Application packaged using poetry2nix";
|
||||||
|
|
||||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
inputs.flake-utils.url = "github:numtide/flake-utils?rev=0f8662f1319ad6abf89b3380dd2722369fc51ade";
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs?rev=37b6b161e536fddca54424cf80662bce735bdd1e";
|
||||||
inputs.poetry2nixSrc = {
|
inputs.poetry2nix.url = "github:nix-community/poetry2nix?rev=7b71679fa7df00e1678fc3f1d1d4f5f372341b63";
|
||||||
url = "github:nix-community/poetry2nix";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
|
||||||
|
{
|
||||||
|
# Nixpkgs overlay providing the application
|
||||||
|
overlay = nixpkgs.lib.composeManyExtensions [
|
||||||
|
poetry2nix.overlay
|
||||||
|
(final: prev: {
|
||||||
|
# The application
|
||||||
|
deepdog = prev.poetry2nix.mkPoetryApplication {
|
||||||
|
overrides = final.poetry2nix.overrides.withDefaults (self: super: {
|
||||||
|
# …
|
||||||
|
# workaround https://github.com/nix-community/poetry2nix/issues/568
|
||||||
|
pdme = super.pdme.overridePythonAttrs (old: {
|
||||||
|
buildInputs = old.buildInputs or [ ] ++ [ final.python39.pkgs.poetry-core ];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
projectDir = ./.;
|
||||||
|
};
|
||||||
|
deepdogEnv = prev.poetry2nix.mkPoetryEnv {
|
||||||
|
overrides = final.poetry2nix.overrides.withDefaults (self: super: {
|
||||||
|
# …
|
||||||
|
# workaround https://github.com/nix-community/poetry2nix/issues/568
|
||||||
|
pdme = super.pdme.overridePythonAttrs (old: {
|
||||||
|
buildInputs = old.buildInputs or [ ] ++ [ final.python39.pkgs.poetry-core ];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
projectDir = ./.;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
} // (flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ self.overlay ];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
apps = {
|
||||||
|
deepdog = pkgs.deepdog;
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, poetry2nixSrc }:
|
defaultApp = pkgs.deepdog;
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
devShell = pkgs.mkShell {
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
poetry2nix = poetry2nixSrc.lib.mkPoetry2Nix { inherit pkgs; };
|
|
||||||
in {
|
|
||||||
packages = {
|
|
||||||
deepdogApp = poetry2nix.mkPoetryApplication {
|
|
||||||
projectDir = self;
|
|
||||||
python = pkgs.python39;
|
|
||||||
preferWheels = true;
|
|
||||||
};
|
|
||||||
deepdogEnv = poetry2nix.mkPoetryEnv {
|
|
||||||
projectDir = self;
|
|
||||||
python = pkgs.python39;
|
|
||||||
preferWheels = true;
|
|
||||||
overrides = poetry2nix.overrides.withDefaults (self: super: {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
default = self.packages.${system}.deepdogEnv;
|
|
||||||
};
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
inputsFrom = [ self.packages.${system}.deepdogEnv ];
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.poetry
|
pkgs.poetry
|
||||||
self.packages.${system}.deepdogEnv
|
pkgs.deepdogEnv
|
||||||
self.packages.${system}.deepdogApp
|
pkgs.deepdog
|
||||||
pkgs.just
|
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export DO_NIX_CUSTOM=1
|
export DO_NIX_CUSTOM=1
|
||||||
'';
|
'';
|
||||||
|
packages = [ pkgs.nodejs-16_x ];
|
||||||
};
|
};
|
||||||
}
|
|
||||||
);
|
}));
|
||||||
}
|
}
|
||||||
|
54
justfile
54
justfile
@ -1,54 +0,0 @@
|
|||||||
|
|
||||||
# execute default build
|
|
||||||
default: build
|
|
||||||
|
|
||||||
# builds the python module using poetry
|
|
||||||
build:
|
|
||||||
echo "building..."
|
|
||||||
poetry build
|
|
||||||
|
|
||||||
# print a message displaying whether nix is being used
|
|
||||||
checknix:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euxo pipefail
|
|
||||||
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
|
|
||||||
echo "In an interactive nix env."
|
|
||||||
else
|
|
||||||
echo "Using poetry as runner, no nix detected."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# format code
|
|
||||||
fmt:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euxo pipefail
|
|
||||||
if [[ "${DO_NIX_CUSTOM:=0}" -eq 1 ]]; then
|
|
||||||
black .
|
|
||||||
else
|
|
||||||
poetry run black .
|
|
||||||
fi
|
|
||||||
find deepdog -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
|
|
||||||
release:
|
|
||||||
./scripts/release.sh
|
|
||||||
|
|
||||||
htmlcov:
|
|
||||||
poetry run pytest --cov-report=html
|
|
731
poetry.lock
generated
731
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "deepdog"
|
name = "deepdog"
|
||||||
version = "0.7.9"
|
version = "0.7.8"
|
||||||
description = ""
|
description = ""
|
||||||
authors = ["Deepak Mallubhotla <dmallubhotla+github@gmail.com>"]
|
authors = ["Deepak Mallubhotla <dmallubhotla+github@gmail.com>"]
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ scipy = "1.10"
|
|||||||
pytest = ">=6"
|
pytest = ">=6"
|
||||||
flake8 = "^4.0.1"
|
flake8 = "^4.0.1"
|
||||||
pytest-cov = "^4.1.0"
|
pytest-cov = "^4.1.0"
|
||||||
mypy = "^1.10"
|
mypy = "^1.9"
|
||||||
python-semantic-release = "^7.24.0"
|
python-semantic-release = "^7.24.0"
|
||||||
black = "^22.3.0"
|
black = "^22.3.0"
|
||||||
syrupy = "^4.0.8"
|
syrupy = "^4.0.8"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user