Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StationConfigurator #1256

Closed
Closed
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
e6ac534
initial commit from code from qdev wrappers
Dominik-Vogel Sep 3, 2018
f51c327
add ruamel to environment
Dominik-Vogel Sep 3, 2018
fa3715c
add revive option
Dominik-Vogel Sep 3, 2018
3c36b6d
Merge branch 'master' into station_configurator
jenshnielsen Sep 5, 2018
1ac4d60
Merge branch 'master' of git://github.com/QCoDeS/Qcodes into station_…
Dominik-Vogel Sep 7, 2018
6e5d8cb
add ruamel.yaml dependency the right way
Dominik-Vogel Sep 7, 2018
31b3239
fix dynamic method creation in load_file
Dominik-Vogel Sep 7, 2018
1d4c53d
Merge branch 'station_configurator' of github.com:Dominik-Vogel/Qcode…
Dominik-Vogel Sep 7, 2018
97a587a
add as partial not method type, remove methods on the fly
Dominik-Vogel Sep 7, 2018
94053da
Treat monitor parameters as list again
Dominik-Vogel Sep 7, 2018
7ff32f9
move station configurator to station
Dominik-Vogel Sep 7, 2018
ef30daf
fixing get_raw/set_raw ci for `Parameter`
Dominik-Vogel Sep 10, 2018
1201efe
disable warning of hidden method get_raw, set_raw
Dominik-Vogel Sep 10, 2018
0a2ba5f
revert changes to get/set wrapping and make comment explicit
Dominik-Vogel Sep 10, 2018
d291a92
Merge branch 'master' into station_configurator
Dominik-Vogel Sep 10, 2018
1470363
comment pylint disable
Dominik-Vogel Sep 10, 2018
df697a7
enable creation of station without config
Dominik-Vogel Sep 10, 2018
28dc9e4
Merge branch 'station_configurator' of github.com:Dominik-Vogel/Qcode…
Dominik-Vogel Sep 10, 2018
313a8a3
fix additional `.station.`
Dominik-Vogel Sep 11, 2018
a24adac
include Mikails changes for snapshotting and validation
astafan8 Sep 11, 2018
cbed36c
add DRYness
Dominik-Vogel Sep 11, 2018
c5a47fb
Merge branch 'master' into station_configurator
Dominik-Vogel Sep 11, 2018
1aad9dd
remove whitespace
Dominik-Vogel Sep 11, 2018
4889013
Merge branch 'master' of https://github.com/QCoDeS/Qcodes into statio…
Dominik-Vogel Apr 25, 2019
629ed82
remove pyyaml
Dominik-Vogel Apr 25, 2019
4986b29
extract YAML importer to qcodes utils
Dominik-Vogel Apr 25, 2019
ad03d8e
give station some code love
Dominik-Vogel Apr 25, 2019
b447456
refactor load_config_file
Dominik-Vogel Apr 26, 2019
e4adf76
load config dynamically, extract load_config (from string)
Dominik-Vogel Apr 30, 2019
1156e8b
fix enable_forced_reconnect bug
Dominik-Vogel Apr 30, 2019
c1844f9
add tests: instatiation, snapshot, forced_reconnect
Dominik-Vogel Apr 30, 2019
36d8fe5
fix delegate parameter
Dominik-Vogel Apr 30, 2019
f3617f2
improve error message for instrument not found in config
Dominik-Vogel Apr 30, 2019
e43ccf1
enable to change instrument name on init
Dominik-Vogel Apr 30, 2019
960ff0f
add a bunch of tests
Dominik-Vogel Apr 30, 2019
cb33d85
Merge branch 'master' into station_configurator
Dominik-Vogel Apr 30, 2019
8b1adb0
Introduce `get_qcodes_path` which is ci save
Dominik-Vogel May 1, 2019
22489dc
Fix typing
Dominik-Vogel May 1, 2019
b9492d6
Merge branch 'station_configurator' of github.com:Dominik-Vogel/Qcode…
Dominik-Vogel May 1, 2019
56065c4
Apply fixes from codacy
Dominik-Vogel May 2, 2019
c4a1438
Remove unused import
Dominik-Vogel May 2, 2019
8cef3b0
Fix signatures of `get_raw` and `set_raw`
Dominik-Vogel May 2, 2019
011492a
Add `ruamel.yaml` to requirements
Dominik-Vogel May 2, 2019
f7b52b0
Exclusively use ruamel.yaml i.e pip version
Dominik-Vogel May 2, 2019
3d5c269
Use `get_qcodes_path` in all tests
Dominik-Vogel May 2, 2019
b9b9be7
Add separator at the end of `get_qcodes_path`
Dominik-Vogel May 2, 2019
b132a76
Fix case for sims file
Dominik-Vogel May 3, 2019
eb08805
Reformulate comment `StationConfigurator->Station`
astafan8 May 3, 2019
b277193
Apply suggestions from code review
astafan8 May 3, 2019
55c2230
Make station adhere to pep8
Dominik-Vogel May 6, 2019
050c5e0
Update qcodes/tests/test_station.py
astafan8 May 6, 2019
64285d4
Operate on copy of options when adding parameter
Dominik-Vogel May 6, 2019
0978122
Merge branch 'station_configurator' of github.com:Dominik-Vogel/Qcode…
Dominik-Vogel May 6, 2019
2710531
Rename `station_configurator` to station everywhere including config
Dominik-Vogel May 6, 2019
77c142f
Fix indent `assert` for `pytest.raises`
Dominik-Vogel May 6, 2019
3629aa5
Use `Optional` over `Union[x, None]`
Dominik-Vogel May 6, 2019
f6cfa6a
Rename to `station_config_has_been_loaded`
Dominik-Vogel May 6, 2019
05822ce
Fix indentation
Dominik-Vogel May 6, 2019
e87fed2
Add comments to path resolution test
Dominik-Vogel May 6, 2019
0c95182
Fix `simple_mock_station` dependency on example_config
Dominik-Vogel May 6, 2019
b692d43
Update qcodes/tests/test_station.py
astafan8 May 6, 2019
d2e1889
Rename component from `Station` to `Config`
Dominik-Vogel May 6, 2019
bb315dc
Update qcodes/station.py
astafan8 May 7, 2019
a91a44f
Implement Mikhails suggestions
Dominik-Vogel May 7, 2019
502bd7e
Merge branch 'station_configurator' of github.com:Dominik-Vogel/Qcode…
Dominik-Vogel May 7, 2019
723c3c8
Add test for revive instance
Dominik-Vogel May 7, 2019
0c17813
Extract method: `close_and_remove_instrument`
Dominik-Vogel May 7, 2019
2cf7a0f
Refactor `load_instrument`
Dominik-Vogel May 7, 2019
bc5882b
Refactor `load_instrument`
Dominik-Vogel May 7, 2019
c0bca08
Add `test_dynamic_reload_of_file`
Dominik-Vogel May 7, 2019
191b8c9
Add tests for DelegateParameter
Dominik-Vogel May 7, 2019
658ff3c
Export DelegateParameter to qcodes root init
astafan8 May 8, 2019
9b4a7d0
DelegateParameter to parameter.py module docstring
astafan8 May 8, 2019
63702c4
Add example notebook about Station
astafan8 May 8, 2019
e34d72b
Refer Station example notebook in community guide
astafan8 May 8, 2019
acded1e
Refer to Station notebook in snapshots notebook
astafan8 May 8, 2019
6f3a94f
Make `Monitor` optional
Dominik-Vogel May 9, 2019
ebbbe6d
Merge branch 'station_configurator' of github.com:Dominik-Vogel/Qcode…
Dominik-Vogel May 9, 2019
7d343f9
Remove trailing whitespaces
Dominik-Vogel May 9, 2019
aa63d5b
Fix typing, add `checked_getattr`
Dominik-Vogel May 9, 2019
b351b7f
Clean up comment
Dominik-Vogel May 9, 2019
2f52bdf
Remove warning when creating station without default config
Dominik-Vogel May 9, 2019
ea3e8df
Dont convert non-grid dataframe to xarray - slow
astafan8 May 9, 2019
fc000c6
Fix link to Station example notebook in RST docs
astafan8 May 9, 2019
20befaf
Fix lists and links sphinx rendering
astafan8 May 9, 2019
bdc38a8
Fix lists and link rendering in sphinx again
astafan8 May 9, 2019
23d9e3b
Use 'station' qcodes config entry
astafan8 May 9, 2019
d32badd
Improve qcodes config schema for 'station' field
astafan8 May 9, 2019
bfc1574
Add proper fix for slicing multiindex dataframe
astafan8 May 9, 2019
6329a17
Remove warnings from station notebook, minor fixes
astafan8 May 9, 2019
33ebe86
Add important clarifications on add_parameter and exponential numbers…
astafan8 May 9, 2019
b7608cb
Note exponental numbers formal in station notebook
astafan8 May 10, 2019
a1713e0
Note simulated instrument in station notebook
astafan8 May 10, 2019
3768f2f
Fix style in station.py
astafan8 May 10, 2019
d0ceb72
Merge branch 'master' into station_configurator
astafan8 May 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion environment.yml
Expand Up @@ -22,11 +22,11 @@ dependencies:
- pyyaml
- lxml
- scipy
- ruamel_yaml
- gitpython
- pandas
- testpath>=0.4.2 # 0.4.1 is bad due to https://github.com/conda-forge/testpath-feedstock/issues/7
- tqdm
- pip:
- websockets>=7.0
- broadbean>=0.9.1
- ruamel.yaml
21 changes: 2 additions & 19 deletions qcodes/dataset/descriptions.py
Expand Up @@ -2,9 +2,11 @@
from typing import Dict, Any, Union, cast
import json

from qcodes.utils.helpers import YAML
from qcodes.dataset.dependencies import (InterDependencies,
InterDependencies_,
new_to_old)

SomeDeps = Union[InterDependencies, InterDependencies_]


Expand Down Expand Up @@ -81,26 +83,10 @@ def _is_description_old_style(serialized_object: Dict[str, Any]) -> bool:
else:
return False

@staticmethod
def _ruamel_importer():
try:
from ruamel_yaml import YAML
except ImportError:
try:
from ruamel.yaml import YAML
except ImportError:
raise ImportError('No ruamel module found. Please install '
'either ruamel.yaml or ruamel_yaml to '
'use the methods to_yaml and from_yaml')
return YAML

def to_yaml(self) -> str:
"""
Output the run description as a yaml string
"""

YAML = self._ruamel_importer()

yaml = YAML()
with io.StringIO() as stream:
yaml.dump(self.serialize(), stream=stream)
Expand All @@ -120,9 +106,6 @@ def from_yaml(cls, yaml_str: str) -> 'RunDescriber':
Parse a yaml string (the return of `to_yaml`) into a RunDescriber
object
"""

YAML = cls._ruamel_importer()

yaml = YAML()
# yaml.load returns an OrderedDict, but we need a dict
ser = dict(yaml.load(yaml_str))
Expand Down
59 changes: 57 additions & 2 deletions qcodes/instrument/parameter.py
Expand Up @@ -930,8 +930,11 @@ def __init__(self, name: str,
**kwargs) -> None:
super().__init__(name=name, instrument=instrument, vals=vals, **kwargs)

# Enable set/get methods if get_cmd/set_cmd is given
# Called first so super().__init__ can wrap get/set methods
# Enable set/get methods from get_cmd/set_cmd if given and
# no `get`/`set` or `get_raw`/`set_raw` methods have been defined
# in the scope of this class.
# (previous call to `super().__init__` wraps existing get_raw/set_raw to
# get/set methods)
if not hasattr(self, 'get') and get_cmd is not False:
if get_cmd is None:
if max_val_age is not None:
Expand Down Expand Up @@ -2012,6 +2015,58 @@ def set_raw(self, value: Union[int, float]) -> None:
self._wrapped_parameter.set(instrument_value)


class DelegateParameter(Parameter):
astafan8 marked this conversation as resolved.
Show resolved Hide resolved
Dominik-Vogel marked this conversation as resolved.
Show resolved Hide resolved
"""
The `DelegateParameter` wraps a given `source`-parameter. Setting/getting
it results in a set/get of the source parameter with the provided
arguments.

The reason for using a `DelegateParameter` instead of the source parameter
is to provide all the functionality of the Parameter base class without
overwriting properties of the source: for example to set a different
Scaling factor and unit on the `DelegateParameter` without changing those
in the source parameter
"""

def __init__(self, name: str, source: Parameter, *args, **kwargs):
self.source = source

for ka, param in zip(('unit', 'label', 'snapshot_value'),
('unit', 'label', '_snapshot_value')):
kwargs[ka] = kwargs.get(ka, getattr(self.source, param))

for cmd in ('set_cmd', 'get_cmd'):
if cmd in kwargs:
raise KeyError(f'It is not allowed to set "{cmd}" of a '
f'DelegateParameter because the one of the '
f'source parameter is supposed to be used.')

super().__init__(name, *args, **kwargs)

# Disable the warnings until MultiParameter and ArrayParameter have been
# replaced and name/label/unit can live in _BaseParameter
# pylint: disable=method-hidden
def get_raw(self):
return self.source.get()

# same as for `get_raw`
# pylint: disable=method-hidden
def set_raw(self, value):
self.source(value)

def snapshot_base(self,
update: bool = False,
params_to_skip_update: Sequence[str] = None):
snapshot = super().snapshot_base(
update=update,
params_to_skip_update=params_to_skip_update
)
snapshot.update(
{'source_parameter': self.source.snapshot(update=update)}
)
return snapshot


def expand_setpoints_helper(parameter: ParameterWithSetpoints) -> List[
Tuple[_BaseParameter, numpy.ndarray]]:
"""
Expand Down