Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
pelinski committed Dec 16, 2024
2 parents b2517ab + ad5aca5 commit c77445b
Show file tree
Hide file tree
Showing 21 changed files with 2,306 additions and 1,728 deletions.
7 changes: 4 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pypi"
jupyter = "==1.1.1"
bitarray = "==3.0.0"
notebook = "==7.2.2"
websockets = "==12.0"
websockets = "==14.1"
ipykernel = "==6.29.5"
nest-asyncio = "==1.6.0"
aiofiles = "==24.1.0"
Expand All @@ -17,12 +17,13 @@ numpy = "==1.26.0"
bokeh = "==2.4.3"
panel = "==0.14.4"
jupyter-bokeh = "==3.0.5"
pandas = "==2.2.3"

[dev-packages]
twine = "*"
pip-chill = "*"
sphinx = "*"
sphinx-rtd-theme = "*"
sphinx = "==7.4.7"
sphinx-rtd-theme = "==3.0.2"
build = "*"
pipdeptree = "*"

Expand Down
842 changes: 492 additions & 350 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dev/dev.prepare-requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ def filter_pybela_packages(file_path):
for line in lines:
if 'pybela' in line and line.startswith('#'):
pybela_packages.append(line.split('#')[1].split(' ')[1])

print(pybela_packages)
return pybela_packages


def write_pybela_packages_to_file(pybela_packages, output_file_path):
print(f"Writing pybela packages to file: {output_file_path}")
with open(output_file_path, 'w') as file:
for package in pybela_packages:
file.write(f"{package}\n")


# Example usage
file_path = 'pip-chill.txt'
output_file_path = 'requirements.txt'
pybela_packages = filter_pybela_packages(file_path)
Expand Down
2 changes: 1 addition & 1 deletion dev/dev.test-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ echo "\nCreating test-env..."
python -m venv test-env
source test-env/bin/activate
echo "\nInstalling pybela from dist..."
pip install ../dist/pybela-1.0.2-py3-none-any.whl
pip install ../dist/pybela-2.0.0-py3-none-any.whl
echo "\nRunning test.py..."
python test.py
deactivate
Expand Down
18 changes: 13 additions & 5 deletions pybela/Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ def start_controlling(self, variables=[]):

async def async_wait_for_control_mode_to_be_set(variables=variables):
# wait for variables to be set as 'controlled' in list
_controlled_status = self.get_controlled_status(
_controlled_status = await self._async_get_controlled_status(
variables) # avoid multiple calls to list
while not all([_controlled_status[var] for var in variables]):
await asyncio.sleep(0.5)
await asyncio.sleep(0.2)

asyncio.run(async_wait_for_control_mode_to_be_set(variables=variables))
self.loop.run_until_complete(
async_wait_for_control_mode_to_be_set(variables=variables))

_print_info(
f"Started controlling variables {variables}... Run stop_controlling() to stop controlling the variable values.")
Expand All @@ -58,12 +59,13 @@ def stop_controlling(self, variables=[]):

async def async_wait_for_control_mode_to_be_set(variables=variables):
# wait for variables to be set as 'uncontrolled' in list
_controlled_status = self.get_controlled_status(
_controlled_status = await self._async_get_controlled_status(
variables) # avoid multiple calls to list
while all([_controlled_status[var] for var in variables]):
await asyncio.sleep(0.5)

asyncio.run(async_wait_for_control_mode_to_be_set(variables=variables))
self.loop.run_until_complete(
async_wait_for_control_mode_to_be_set(variables=variables))

_print_info(f"Stopped controlling variables {variables}.")

Expand Down Expand Up @@ -96,6 +98,12 @@ def send_value(self, variables, values):
self.send_ctrl_msg(
{"watcher": [{"cmd": "set", "watchers": variables, "values": values}]})

async def _async_get_controlled_status(self, variables=[]):
"""Async version of get_controller_status"""
variables = self._var_arg_checker(variables)
_list = await self._async_list()
return {var['name']: var['controlled'] for var in _list['watchers'] if var['name'] in variables}

def get_controlled_status(self, variables=[]):
"""Gets the controlled status (controlled or uncontrolled) of the variables
Expand Down
Loading

0 comments on commit c77445b

Please sign in to comment.