Repository: pylhc/omc3 (language: python)

Issue:
[Bug]: Pypi install does not include kmod sequences
### Documentation

- [X] Yes

### Operating System

CentOS 7.9

### Python Version

3.7

### Package Version

2.1

### Bug Description

When running the `run_kmod` script after installing it via `pip install omc3`, an error occurs as the files in the `sequence` directory in the `kmod` folder are missing.

### Steps to Reproduce

_No response_

### Relevant output

_No response_

### Possible Fix Implementation

Add `graft omc3/kmod/sequences ` to the `MANIFEST.in`.
[Bug]: Kmod default errors
### Documentation

- [X] Yes

### Operating System

CentOS 7.9

### Python Version

3.7

### Package Version

2.1

### Bug Description

If the `run_kmod` is run without specifying with all errors, the script crashes with an Attribute Error: 'ip'

### Steps to Reproduce

Execute `run_kmod` script without the options `cminus`, 'errorK', 'errorL'

### Relevant output

```shell
self = {'betastar_and_waist': {'X': array([ 200., -100.]), 'Y': array([ 200., -100.])}, 'working_directory': PosixPath('/tmp/....L4B2'], 'interaction_point': None, 'measurement_dir': None, 'phase_weight': 0.0, 'model_dir': None, 'outputdir': None}
key = 'ip'

    def __getattr__(self, key):
        """Needed to raise the correct exceptions."""
        try:
>           return super(DotDict, self).__getitem__(key)
E           AttributeError: 'ip'
```


### Possible Fix Implementation

In `run_kmod` L 304, options.ip should be renamed to options.interaction_point, as this was missed during some renaming.
Additionally, a test should cover this scenario.


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09b7d9bf3..2c24ee5ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
 # OMC3 Changelog
 
+#### 2022-01-10
+
+- Fixed:
+  - Sequences for K-Modulation are now included in PyPi package
+  - Bug fixed where default errors in K-Modulation would not have been taken into account
+  
 #### 2021-07-14 
 _by jdilly_
 
diff --git a/MANIFEST.in b/MANIFEST.in
index 2e533a9f9..1afb76a6c 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,4 +1,5 @@
 include omc3/bin/madx*
 graft omc3/model/accelerators 
 graft omc3/model/madx_macros 
+graft omc3/kmod/sequences 
 graft omc3/plotting/styles
diff --git a/omc3/__init__.py b/omc3/__init__.py
index 7cf2ea162..8fd4f7c1d 100644
--- a/omc3/__init__.py
+++ b/omc3/__init__.py
@@ -11,7 +11,7 @@
 __title__ = "omc3"
 __description__ = "An accelerator physics tools package for the OMC team at CERN."
 __url__ = "https://github.com/pylhc/omc3"
-__version__ = "0.2.1"
+__version__ = "0.2.2"
 __author__ = "pylhc"
 __author_email__ = "pylhc@github.com"
 __license__ = "MIT"
diff --git a/omc3/run_kmod.py b/omc3/run_kmod.py
index 8128a4063..e908d16de 100644
--- a/omc3/run_kmod.py
+++ b/omc3/run_kmod.py
@@ -301,7 +301,7 @@ def convert_betastar_and_waist(bs):
 
 def check_default_error(options, error):
     if options[error] is None:
-        options[error] = DEFAULTS_IP[error] if options.ip is not None else DEFAULTS_CIRCUITS[error]
+        options[error] = DEFAULTS_IP[error] if options.interaction_point is not None else DEFAULTS_CIRCUITS[error]
     return options
 
 


Test patch:
diff --git a/tests/accuracy/test_kmod.py b/tests/accuracy/test_kmod.py
index 0c8bbd463..7dc86968a 100644
--- a/tests/accuracy/test_kmod.py
+++ b/tests/accuracy/test_kmod.py
@@ -321,6 +321,23 @@ def test_kmod_outputdir_default(tmp_path, _kmod_inputs_path):
     assert (tmp_path / "MQM.7L4.B2-MQY.6L4.B2").exists()
 
 
+@pytest.mark.extended
+def test_kmod_error_default(tmp_path, _kmod_inputs_path):
+    """
+    Test that default errors work.
+    """
+    [shutil.copy(kmod_input, tmp_path) for kmod_input in _kmod_inputs_path.glob("*L4B2*")]
+    analyse_kmod(
+        betastar_and_waist=[200.0, -100.0],
+        working_directory=tmp_path,
+        beam=2,
+        simulation=False,
+        no_sig_digits=True,
+        no_plots=False,
+        circuits=["RQ7.L4B2", "RQ6.L4B2"],
+    )
+
+
 @pytest.fixture()
 def _kmod_inputs_path() -> Path:
     return Path(__file__).parent.parent / "inputs" / "kmod"