instrumentserver.params#
Functions
|
|
|
Classes
|
A parameter that can carry a Lock naming another parameter as its Target. |
|
A Parameter Group: a plain container of parameters and nested Parameter Groups inside a Parameter Manager. |
|
A virtual instrument that acts as a manager for a collection of arbitrary parameters and groups of parameters. |
|
- class instrumentserver.params.ManagedParameter(name: str, path: str | None = None, **kwargs: Any)[source]#
Bases:
ParameterA parameter that can carry a Lock naming another parameter as its Target.
While the Lock is locked, the parameter answers
getwith the Target’s value and refusessetwith aValueErrornaming the Target: values are pulled on get, nothing is ever pushed into a Follower (ADR-0002). Locking never touches the own cached value, so unlocking exposes the own value again. With no Lock, or with a Lock that is present but unlocked, the parameter behaves like a plainParameter; an unlocked Lock only remembers its Target.- property path: str#
The parameter’s full dotted path with the instrument name, the form Locks and files use (
parameter_manager.q01.x); for a standalone parameter, its plain name.
- set_raw(value: Any) None[source]#
Store the value while not locked; while locked, refuse with a
ValueErrornaming the full dotted paths of Follower and Target.
- snapshot_base(update: bool | None = True, params_to_skip_update: Sequence[str] | None = None) Dict[str, Any][source]#
Snapshot with a
lockentry while a Lock is present; while locked, the reportedvalueis the Target’s value.With
update=Truethe base snapshot already asks this parameter, whose locked get answers with the Target’s value, so the Target is not read a second time. With a falsyupdatethe Target is read directly — not its cache — so that each hop of a chain reads according to its own state (D7).
- class instrumentserver.params.ParameterGroup(name: str, metadata: Mapping[Any, Any] | None = None, label: str | None = None)[source]#
Bases:
InstrumentBaseA Parameter Group: a plain container of parameters and nested Parameter Groups inside a Parameter Manager.
It holds parameters and nested Parameter Groups and offers the tree helpers (dotted-path add/remove/get/set, listing, tree building), but has no file, profile, Type or Lock logic of its own. Every submodule of a Parameter Manager is a Parameter Group; only the root is the Parameter Manager, which extends the Parameter Group with those responsibilities. When a Parameter Group belongs to a Parameter Manager, its public
add_parameter/remove_parameterroute to the root, soManagedParametercreation and the Lock cleanup always happen; a standalone Parameter Group behaves as a plain container.- add_parameter(name: str, **kw: Any) None[source]#
Add a parameter.
A Parameter Group that belongs to a Parameter Manager routes the call to the root, with the path made relative to it (
<group path>.<name>), so the parameter is created as aManagedParameterthat can carry a Lock (D15). A standalone Parameter Group creates a plain qcodesParameter.- Parameters:
name – Name of the parameter. If the name contains .`s, then an element before a dot is interpreted as a submodule. Multiple dots represent nested submodules. I.e., when we supply ``foo.bar.foo2` we have a top-level submodule
foo, containing a submodulebar, containing the parameterfoo2. Submodules are generated on demand.kw – Any keyword arguments will be passed on to qcodes.Instrument.add_parameter, except: -
set_cmdis always set toNone-parameter_classdefaults toqcodes.Parameter-valsdefaults toqcodes.utils.validators.Anything().
- Returns:
None.
- get(param_name: str) Any[source]#
Shortcut for getting a parameter from its name.
- Parameters:
param_name – The name of a parameter of this instrument.
- Returns:
The current value of the parameter.
Note
This is deprecated. Call get directly on the parameter.
- parameter(name: str) ParameterBase[source]#
Get a parameter object from the manager.
- Parameters:
name – the full name
- Returns:
the parameter
- remove_parameter(param_name: str, cleanup: bool = True) None[source]#
Remove a parameter.
A Parameter Group that belongs to a Parameter Manager routes the call to the root, with the path made relative to it, so the root’s Lock cleanup happens before the deletion (D3, D15). A standalone Parameter Group deletes directly.
- Parameters:
param_name – Name of the parameter; dotted names traverse nested Parameter Groups.
cleanup – Whether to remove emptied submodules afterwards.
- class instrumentserver.params.ParameterManager(name: str)[source]#
Bases:
Broadcaster,ParameterGroupA virtual instrument that acts as a manager for a collection of arbitrary parameters and groups of parameters.
Allows extra-easy on-the-fly addition/removal of new parameters.
The Parameter Manager is the root of the parameter tree. It extends the Parameter Group with file, profile, Lock, and Type logic; its submodules are plain Parameter Groups.
It implements the Broadcaster contract, so the Server can register itself as a broadcast sink when the Parameter Manager joins the Station. Every Lock method that changes a Lock emits one
pm-lock-updateBroadcast per affected Follower (D10), andremove_parameteremits them for the Locks that deleting a Target drops. Every Type-editing method emitspm-type-updatewith the edited Type’s freshPMTypeBluePrint(D22), and the parameters the Type edits andadd_instance()create as side effects are re-emitted asparameter-creationBroadcasts (ADR-0003); directadd_parametercalls keep being announced by the Server, so nothing is announced twice. Declaring a Type Lock withlock_type_parameter()and removing it withunlock_type_parameter()do both: they emit thepm-lock-updateBroadcasts of the Locks the declaration creates and thepm-type-updateof the edited Type, and every new Instance gets the existing Type Locks of its Type at creation (D17). Removing a parameter that is the stored Target of Type Locks drops the Locks pointing at it and clears those Type Locks, emitting onepm-type-updateper affected Type (D18).For the parameter manager to recognize other profiles in disk, the profile filename needs to start with ‘parameter_manager-’ and end with ‘.json’ with the name of the profile in the middle. For example, ‘parameter_manager-qubit1.json’ represents the profile qubit1
- add_instance(type_name: str, name: str) None[source]#
Create the Instance
nameof the Typetype_name(D14): every effective parameter path of the Type that is missing undername— together with the Parameter Groups on the way — is created with the entry’s default value and unit through the ordinaryadd_parameter()path, and every parameter that exists at a target path already is kept untouched, with its own value and unit.nameis a dotted submodule path relative to this Parameter Manager ("q01"or"q01.readout"), so nested Instances are allowed. After a successful callnamecarries the whole effective set with the units the Type declares, so it is an Instance ininstances_of()— unless the Type is empty: an empty Type has no Instances (D12), creates nothing and raises nothing, and the submodule is not created for it.Raises
ValueError— creating nothing — naming every offending path when no such Type exists, whennameis empty or has an empty segment, whennamestarts with the reserved Globals name_globals(D18), when a parameter already exists at an effective path with a unit different from the one the Type declares (the unit-conflict scan runs over every effective path before anything is created, D14), or when a target path cannot be created because a segment ofnameor of the target is an existing parameter, or the final segment of a target is an existing Parameter Group.After the Instance is created it emits one
parameter-creationBroadcast per parameter it created, in creation order, followed by onepm-lock-updateBroadcast per Type Lock it applied to the new Instance (D17, D22, ADR-0003); the call edits no Type, so it emits nopm-type-update. A failed validation emits nothing. As a new Instance,namegets the existing Type Locks of this Type and of every Type nesting it applied to its parameters at their locked effective entries — a parameter the call kept (D14) included, since a Lock changes neither its own value nor its unit. A kept parameter that already carries a Lock on another Target, a stored Target that no longer exists and a Lock that would close a cycle are skipped, collected into onelogger.warning; the creation itself still succeeds. Submodules that were Instances before the call are untouched.- Parameters:
type_name – Name of the Type.
name – Dotted submodule path of the Instance, relative to this Parameter Manager.
- add_nested_type(type_name: str, submodule: str, nested_type: str) None[source]#
Require the Nested Type
nested_typeat the submodulesubmoduleof the Typetype_name(D11), and write the nested Type’s effective parameter set under that submodule into every Instance oftype_name— and of every Type nesting it — that lacks the parameters, with each entry’s default value and unit (D13).Raises
ValueError— leaving the registry and the parameter tree untouched — naming every offending name or path when a Type does not exist, whensubmoduleis empty, has an empty segment or starts with the reserved Globals name_globals(D18), when the submodule already requires a Nested Type, when the nesting would close a cycle (type_name == nested_typeincluded), when the resulting effective parameter set oftype_nameor of any Type nesting it would contain a path twice, or when a target path cannot be created because an intermediate segment is an existing parameter, the final segment is an existing Parameter Group, or another target of the same edit is a strict segment-prefix of it.After the edit succeeds it emits one
parameter-creationBroadcast per parameter it created, in creation order, followed by onepm-lock-updateBroadcast per Type Lock it applied to a new Instance and onepm-type-updateBroadcast per affected Type — the edited Type first, then every Type nesting it, whose effective parameter set the nested entries extend (D17, D22, ADR-0003); a failed validation emits nothing. A new Instance — a submodule that is an Instance after the edit but was not one before — gets the existing Type Locks of its Type applied to its parameters at the Type’s locked effective entries, parameters the edit kept included; the Nested Type’s own chain joins the Types whose Type Locks are applied, since nesting it completes the submodules at its position into Instances of it; skips are collected into onelogger.warningand the edit still succeeds.- Parameters:
type_name – Name of the outer Type.
submodule – Name of the submodule that requires the Nested Type.
nested_type – Name of the Nested Type.
- add_parameter(name: str, **kw: Any) None[source]#
Add a parameter, created as a
ManagedParameter.Same dotted-name semantics as
ParameterGroup.add_parameter(), which this method calls; only the parameter class differs, so that the Parameter Manager’s parameters can carry a Lock. The created parameter’spathis set to its full dotted path with the instrument name (parameter_manager.q01.x), the form Locks and files use.Raises
ValueErrornaming the offending path, creating nothing, whennameis the reserved Globals name_globalsor starts with it (D18): the Globals submodule holds only the default Targets of Type Locks, and its parameters are created on demand by_ensure_global_target(), not through the public API. Since a Parameter Group routes itsadd_parameterto the root (D15), this check covers calls made on any Parameter Group of this Parameter Manager as well.- Parameters:
name – Name of the parameter; see
ParameterGroup.add_parameter().kw – Any keyword arguments will be passed on to qcodes.Instrument.add_parameter, as in
ParameterGroup.add_parameter().
- Returns:
None.
- add_type(name: str) None[source]#
Create an empty Type named
namein the Type registry.Raises
ValueErrornaming the name when it is the reserved Globals name_globalsor when a Type with that name exists already; nothing is changed then. A fresh Type has no entries and no Nested Types, so it has no Instances until entries are added. Emits onepm-type-updateBroadcast carrying the new Type’sPMTypeBluePrintafter it is created (D22); a failed validation emits nothing.- Parameters:
name – Name of the Type.
- add_type_parameter(type_name: str, path: str, default: Any = None, unit: str = '') None[source]#
Add an entry to the Type
type_name(D11) and create the parameter atpath— with the entry’s default value and unit — in every Instance of the Type that lacks it, and in every Instance of a Type whose effective parameter set containstype_namethrough nesting (D13). Parameters that already exist at a target path are left alone, whatever their unit; the missing Parameter Groups along a target path are created.Raises
ValueError— leaving the registry and the parameter tree untouched — naming every offending path when no such Type exists, whenpathis empty or has an empty segment, whenpathis already in the Type’s effective parameter set (naming the Type that defines it), whenprefix + pathis already in the effective parameter set of a Type nesting this one — naming every colliding path and the Type whose effective set holds it, since the duplicated path would break every query on that Type — or when a target path cannot be created because an intermediate segment is an existing parameter, the final segment is an existing Parameter Group, or another target of the same edit is a strict segment-prefix of it.After the edit succeeds it emits one
parameter-creationBroadcast per parameter it created, in creation order, followed by onepm-lock-updateBroadcast per Type Lock it applied to a new Instance and onepm-type-updateBroadcast per affected Type — the edited Type first, then every Type nesting it, whose effective parameter set the new entry extends (D17, D22, ADR-0003); a failed validation emits nothing. A new Instance — a submodule that is an Instance of an affected Type after the edit but was not one before — gets the existing Type Locks of that Type applied to its parameters at the Type’s locked effective entries, parameters the edit kept included; skips are collected into onelogger.warningand the edit still succeeds.- Parameters:
type_name – Name of the Type.
path – Relative parameter path of the entry.
default – Default value the created parameters start with.
unit – Unit of the entry and the created parameters.
- static cleanProfileName(name: str) str[source]#
When passed the full file name of a parameter_manager profile, return only the middle string representing the profile’s name.
- static createFromParamDict(paramDict: Dict[str, Any], name: str) ParameterManager[source]#
Create a new ParameterManager instance from a paramDict.
- Parameters:
paramDict – The paramDict object.
name – Name of the instrument in the paramDict (each entry in the paramDict starts with <instrumentName>.[…]).
- Returns:
New ParameterManager instance.
- followers_of(name: str) List[str][source]#
Paths (relative to this Parameter Manager) of every Follower whose Lock points at the parameter at
name, locked and unlocked alike. RaisesValueErrornaming the path when the parameter does not exist.
- fromFile(filePath: str | None = None, deleteMissing: bool = True) None[source]#
Load parameters, Types and Locks from a parameter json file (see
serialize).If the filepath starts with ‘parameter_manager-’ and ends with ‘.json’, selectedProfile is changed to the filename.
- Parameters:
filePath – Path to the json file. If
Noneit looks in the instrument current location directory for a file called “parametermanager_parameters.json”.deleteMissing – If
True, delete parameters currently in the ParameterManager that are not listed in the file.
- fromParamDict(paramDict: Dict[str, Any], deleteMissing: bool = True) None[source]#
Load parameters, Types and Locks from a parameter dictionary (see
serialize).A dictionary without a top-level
versionkey is the legacy flat parameter map and loads exactly as before: parameters only, and the Types and Locks of this Parameter Manager are untouched by the legacy reader.A version-2 profile document (the document
toParamDict()writes, plan decision D19) is validated as a whole before anything is loaded (plan decision D20). The schema is checked withserialize.validateParameterManagerV2(); every remaining problem is collected into oneValueErrornaming all of them (rule 3): every file key must belong to this Parameter Manager (the full-path form with the instrument name), every Type name must be valid (non-empty, not the reserved Globals name_globals), every Nested Type must name a Type of the document, the document’s Types must form no Nested Type cycle and hold no effective parameter path twice, everylockTarget and every non-null Type Lock Target must be aparameterskey of the document, and nolockmay be a self-lock or close a cycle among the document’s Locks (walking Targets regardless of locked/unlocked state, D7). A refused document changes nothing and emits nothing. Any otherversionvalue raisesValueErrornaming it.After the validation the document loads in order (D20): first the Locks of every parameter it lists go away, so setting a stored own value on a currently locked Follower cannot raise (D6); then the parameters with the semantics the reader always had (an existing one is set to its stored own value and unit, a missing one is created — one under the Globals submodule through the internal creation path
_create_managed_parameter(), since the publicadd_parameter()refuses the Globals name (D18) — anddeleteMissing=Trueremoves the parameters the document does not list, dropping their Locks and Type Locks exactly likeremove_parameter()does); then the Types, written straight into the registry as definitions — withdeleteMissing=True, every Type the document does not define is removed — with no Instance side effects (D20): no parameter is created for an Instance and no Type Lock is applied on load, so a partial Instance stays partial and an Instance’s Locks come only from the document’slockentries; then the Locks, each set directly to the stored full-form Target and stored locked state (likelock()creates it after the cycle check, not through alock()/unlock()pair). A parameter the document lists without alockentry ends with no Lock; parameters it does not list keep theirs whendeleteMissing=False.The Broadcasts go out once, after the whole load succeeded (D22, D10): one
pm-type-updateper Type the document wrote, then one with aNonepayload per Type removed, then onepm-lock-updateper Lock that ended different from before the load (Nonewhen it was removed), in tree order. The load emits nothing for the parameter values it sets, and it re-emits noparameter-creation/parameter-deletionBroadcasts for the parameters it creates and removes: the Server’s literal-name detection does not see them either, so a GUI watching this Parameter Manager must refresh its structure after a profile load.- Parameters:
paramDict – Parameter dictionary — a legacy flat map or a version-2 profile document.
deleteMissing – If
True, delete parameters currently in the ParameterManager that are not listed in the file, and remove the Types the file does not define.
- static fullProfileName(name: str) str[source]#
Adds ‘parameter_manager-’ to the beginning of name and adds ‘.json’ at the end.
- get_lock(name: str) PMLockBluePrint | None[source]#
The Lock of the parameter at
name(dotted path relative to this Parameter Manager) as aPMLockBluePrintwhose Target is the full dotted path, orNonewhen it carries no Lock. RaisesValueErrornaming the path when the parameter does not exist.
- get_type(name: str) PMTypeBluePrint[source]#
The Type
nameas aPMTypeBluePrint: its own entries as{path: {default, unit, target}}, its Nested Types as{submodule: type}, and the computed effective parameter set as{path: {unit, from_type}}. RaisesValueErrornaming the name when no such Type exists, and like_effective_parameters()when its Nested Types cycle or its effective set contains a path twice.
- instances_of(type_name: str) List[str][source]#
Paths (relative to this Parameter Manager) of every Instance of the Type
type_name(D12): every Parameter Group at any depth that carries every path of the Type’s effective set with the unit the Type declares; values are irrelevant. The root is never an Instance, the Globals submodule_globalsand everything under it are excluded, and an empty Type has no Instances (ADR-0001). Matching is computed on demand; this query changes no state.Raises
ValueErrornaming the name when no such Type exists, and like_effective_parameters()when its Nested Types cycle or its effective set contains a path twice.- Parameters:
type_name – Name of the Type.
- Returns:
Paths of the Instances, in tree order.
- list_locks() Dict[str, PMLockBluePrint][source]#
All Locks in this Parameter Manager, locked and unlocked alike (D5), as a mapping from the Follower’s path (relative to this Parameter Manager) to its
PMLockBluePrint.
- lock(name: str, target: str) None[source]#
Lock the parameter at
nameto the parameter attarget(dotted paths relative to this Parameter Manager).Creates the Lock, or re-targets it when one exists already, and locks it: while locked,
nameanswersgetwith the Target’s value and refusesset(ADR-0002). The Target must be a parameter of this same Parameter Manager (D8). RaisesValueErrornaming every offending path when a path does not exist (both paths are checked before one error is raised), the Follower cannot carry a Lock, the Lock would be a self-lock, or it would close a cycle (walking Targets regardless of locked/unlocked state, D7). On success emits onepm-lock-updateBroadcast naming the Follower with its new Lock (D10); a failed validation emits nothing.- Parameters:
name – path of the Follower.
target – path of the Target.
- lock_type_parameter(type_name: str, path: str, target: str | None = None) List[str][source]#
Declare the Type Lock of the entry
pathof the Typetype_name(D17): the Target is stored on the entry — the parameter attargetwhen given, the Globals parameter_globals.<type_name>.<path>otherwise — and an ordinary, locked Lock on that Target is put on the entry’s parameter in every current Instance of the Type. The default Globals Target is created on demand with the entry’s default value and unit, through_ensure_global_target().Instance parameters that already carry a Lock on another Target are skipped: they are left untouched, named together with their Target in one
logger.warning, and returned as a list of dotted paths relative to this Parameter Manager (empty when nothing was skipped). A parameter already locked to the same Target stays as it is; an unlocked Lock remembering the same Target is locked again. Declaring the Type Lock again therefore re-applies it to everyone (“lock all”); declaring it with a different Target stores the new one, and the Followers still locked to the old Target count as skipped.Raises
ValueError— before anything is touched — naming every offending path when no such Type exists, whenpathis not an entry of the Type itself (naming the Type that defines it when the path only reaches the effective parameter set through a Nested Type; own entries only, likeset_type_parameter_default()), when an explicittargetdoes not exist as a parameter of this Parameter Manager, and when locking one of the Instance parameters would be a self-lock, close a cycle (walking Targets regardless of locked/unlocked state, D7) or hit a parameter that cannot carry a Lock.On success it emits the Globals parameter’s
parameter-creation(when created), then onepm-lock-updateper Lock it created or relocked — nothing for skipped or already-locked parameters — and finally onepm-type-updatefor the edited Type (D10, D22); the Types nesting it are not named, since their effective parameter set carries units and defining Types, not Targets. A failed validation emits nothing.- Parameters:
type_name – Name of the Type.
path – Relative parameter path of the Type’s own entry.
target – Path of the Target, relative to this Parameter Manager; the default Globals Target when
None.
- Returns:
The skipped Instance parameter paths, in tree order.
- refresh_profiles() List[str][source]#
Goes into the working directory and updates the list of profiles.
- Returns:
List of profiles in the working directory
- relock(name: str) None[source]#
Lock the Lock of the parameter at
name(dotted path relative to this Parameter Manager) to its remembered Target again (D5). RaisesValueErrornaming the paths when the parameter does not exist, carries no Lock, or when the remembered Target is gone or locking to it would close a cycle (D7); relocking an already locked Lock does nothing and logs at INFO level. On a state change emits onepm-lock-updateBroadcast carrying the locked Lock (D10); the no-op path emits nothing.
- remove_lock(name: str) None[source]#
Remove the Lock of the parameter at
name(dotted path relative to this Parameter Manager) entirely: the Target is forgotten and the parameter behaves as a plain parameter again (D5). RaisesValueErrornaming the path when the parameter does not exist or carries no Lock. Emits onepm-lock-updateBroadcast with aNonevalue for the Follower whose Lock was removed (D10).
- remove_nested_type(type_name: str, submodule: str) None[source]#
Remove the Nested Type required at the submodule
submoduleof the Typetype_name(D13): the parameters of the Instances are untouched, and the submodules that no longer carry the whole shape simply stop being Instances (D1).Raises
ValueErrornaming the Type and the submodule when no such Type exists or the submodule requires no Nested Type; nothing is removed then. Emits onepm-type-updateBroadcast per affected Type — the edited Type first, then every Type nesting it, whose effective parameter set loses the nested paths — after the Nested Type is removed (D22); a failed validation emits nothing.- Parameters:
type_name – Name of the Type.
submodule – Name of the submodule that requires the Nested Type.
- remove_parameter(param_name: str, cleanup: bool = True) None[source]#
Remove a parameter, first removing every Lock whose Target it is (ADR-0002): the Followers become plain parameters and answer
getwith their own values again. Onepm-lock-updateBroadcast with aNonevalue is emitted per dropped Lock (D10).When the removed parameter is the stored Target of one or more Type Locks — a Globals parameter, or any parameter an explicit Type Lock points at — the Type Lock is cleared as well (D18): every own entry of every Type whose stored Target it was gets
target=None, and onepm-type-updateBroadcast per affected Type, in registry order and carrying the Type’s freshPMTypeBluePrint, is emitted after thepm-lock-update``s (D22). The Locks a cleared Type Lock had put on Instance parameters are ordinary Locks pointing at the removed parameter, so the same cleanup drops them; a parameter that is no Type Lock Target emits no ``pm-type-update.Same signature and deletion behaviour as
ParameterGroup.remove_parameter(); the path is relative to this Parameter Manager. The deletion itself emits nothing here: the Server announces a directremove_parametercall with aparameter-deletionBroadcast (ADR-0003).
- remove_type(name: str) None[source]#
Remove the Type
namefrom the Type registry.The parameters of Instances are untouched (D13). Raises
ValueErrorwhen no such Type exists, and — naming every Type that nests it — while any other Type still requiresnameas a Nested Type; nothing is removed then. Emits exactly onepm-type-updateBroadcast with aNonepayload after the Type is removed (D22): nobody nests it, so no other Type is affected; a failed validation emits nothing.- Parameters:
name – Name of the Type.
- remove_type_parameter(type_name: str, path: str) None[source]#
Remove the entry at
pathfrom the Typetype_name’s own entries (D13): the parameters of the Instances are untouched, and the submodules that no longer carry the whole shape simply stop being Instances (D1).Raises
ValueErrornaming the path when no such Type exists, whenpathis not an entry of the Type itself — naming the Type that defines it, when the path only reaches the effective parameter set through a Nested Type — and when it is in no effective set at all. Nothing is removed then. Emits onepm-type-updateBroadcast per affected Type — the edited Type first, then every Type nesting it, whose effective parameter set loses the path — after the entry is removed (D22); a failed validation emits nothing.- Parameters:
type_name – Name of the Type.
path – Relative parameter path of the entry.
- selectedProfile#
default location and name of the parameters save file.
- set_type_parameter_default(type_name: str, path: str, value: Any) None[source]#
Set the default value of the Type
type_name’s own entry atpath(D13): the parameters the Instances already carry keep their values, and only parameters created later start with the new default.Raises
ValueErrornaming the path under the same conditions asremove_type_parameter(); nothing is changed then. Emits onepm-type-updateBroadcast carrying the edited Type’s fresh blueprint after the default is set (D22); no Broadcast names a nesting Type, since a Type’s effective parameter set carries units and defining Types, not defaults, so their blueprints are unchanged. A failed validation emits nothing.- Parameters:
type_name – Name of the Type.
path – Relative parameter path of the entry.
value – The entry’s new default value.
- set_type_parameter_unit(type_name: str, path: str, unit: str) None[source]#
Set the unit of the Type
type_name’s own entry atpathand propagate it to that parameter in every Instance of the Type and of every Type whose effective parameter set containstype_namethrough nesting (D13); the target of a propagation is one of the Instance’s parameters by construction, and a parameter already carrying the new unit is simply set again.Raises
ValueErrornaming the path under the same conditions asremove_type_parameter(); nothing is changed then. Emits onepm-type-updateBroadcast per affected Type — the edited Type first, then every Type nesting it, whose effective parameter set carries the changed unit — after the unit is set and propagated (D22); a failed validation emits nothing.- Parameters:
type_name – Name of the Type.
path – Relative parameter path of the entry.
unit – The entry’s and the Instances’ new unit.
- switch_to_profile(profile: str) None[source]#
Switches to the passed profile (D20): the current profile is saved first (the version-2 profile document
toFile()writes), then every parameter, Type and Lock is cleared (_clear_all()), then the new profile is loaded (fromFile(), a legacy flat map or a version-2 document). RaisesValueError— saving, clearing and loading nothing — when the profile does not exist.
- toFile(filePath: str | None = None, name: str | None = None) None[source]#
Save parameters from the instrument into a json file. The file holds the version-2 profile document
toParamDict()returns (plan decision D19), dumped withindent=2, sort_keys=True. If the file being saved is a profile file (starts with ‘parameter_manager-’ and ends with ‘.json’), the selectedProfile is changed to the filename.- Parameters:
filePath – Path to the json file. If
Noneit looks in the instrument current working directory for a file called “parameter_manager-<name_of_this_instrument>.json”.name – If the filePath passed is a directory, The name of the file that it will create follows the convention of “parameter_manager-<name>.json”. If none it will name it the name of the instrument.
- toParamDict(simpleFormat: bool = False, includeMeta: List[str] = ['unit']) Dict[str, Any][source]#
Return the state of this Parameter Manager as a version-2 profile document (plan decision D19):
{"version": 2, "parameters": {...}, "types": {...}}.parametersmaps every parameter’s full dotted path (with the instrument name, like the legacy flat files) to a dict holding the parameter’s own value —ManagedParameter.own_value()for the parameters that can carry a Lock, so a locked Follower saves its own value and never the Target’s (ADR-0002), the cached snapshot value for any plainParameter— the metadataincludeMetaselects (unitby default; Globals parameters are saved like any other, D18), and, only on a parameter that carries a Lock in either state, alockentry{"target": <full dotted Target path>, "locked": <bool>}.typesmaps every Type of the Type registry to its own entries as{path: {"default": ..., "unit": ..., "target": ...}}— the stored full-form Target of the entry’s Type Lock, orNone— and its Nested Types as{submodule: type}; with no Types it is{}.The values are read from the qcodes snapshot with
update=False(the cache, neverget), like the legacy writer this replaces.simpleFormatis kept for signature compatibility but has no effect: a version-2 document always stores the per-parameter dict.includeMetastill selects the per-parameter metadata besidesvalue.- Parameters:
simpleFormat – Ignored (kept for signature compatibility).
includeMeta – List of parameter attributes to include besides value. All keys occurring in snapshots are valid.
- Returns:
The version-2 profile document.
- toggle_lock(name: str) None[source]#
Toggle the Lock of the parameter at
name(dotted path relative to this Parameter Manager): locked becomes unlocked and unlocked becomes locked again (D5). RaisesValueErrornaming the path when the parameter does not exist or carries no Lock, and likerelock()when locking back would close a cycle. Emits onepm-lock-updateBroadcast throughunlock()/relock(), which carry out the change (D10).
- types_of(path: str) List[str][source]#
Names of the Types claiming the parameter at
path(a dotted path relative to this Parameter Manager), innermost first (D16): the Type whose Instance is the deepest submodule above the parameter wins, then the one with the largest effective set, with any remaining tie broken by Type name. A Type claims the parameter when an Instance of it above the parameter — some submodule the parameter lives under — carries the parameter’s path relative to that Instance in its effective set. Parameters under the Globals submodule_globalsare claimed by nothing, since matching excludes_globals(D12). Matching is computed on demand; this query changes no state.Raises
ValueErrornaming the path when no parameter exists there.- Parameters:
path – Path of the parameter.
- Returns:
Claiming Type names, innermost first.
- unlock(name: str) None[source]#
Unlock the Lock of the parameter at
name(dotted path relative to this Parameter Manager): it keeps remembering its Target but answersgetwith its own value again (D5). RaisesValueErrornaming the path when the parameter does not exist or carries no Lock; unlocking an already unlocked Lock does nothing and logs at INFO level. On a state change emits onepm-lock-updateBroadcast carrying the unlocked Lock (D10); the no-op path emits nothing.
- unlock_type_parameter(type_name: str, path: str) None[source]#
Remove the Type Lock of the entry
pathof the Typetype_name(D17): only the rule goes — the entry’s stored Target is cleared and onepm-type-updateBroadcast naming the Type goes out — while the Locks the declaration put on the Instance parameters stay until they are removed individually withremove_lock(). Instances that stop matching keep their Locks either way.Raises
ValueErrornaming the Type and the path when no such Type exists orpathis not an entry of the Type itself; nothing is changed then. An entry that carries no Type Lock is a no-op logged at INFO level that emits nothing (likeunlock()andrelock()).- Parameters:
type_name – Name of the Type.
path – Relative parameter path of the Type’s own entry.
- class instrumentserver.params.ParameterTypes(*values)[source]#
Bases:
Enum- any = 1#
- bool = 5#
- complex = 6#
- integer = 3#
- numeric = 2#
- string = 4#
- instrumentserver.params.paramTypeFromName(name: str) ParameterTypes | None[source]#