Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.10', '3.13', '3.14']

steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -37,17 +37,19 @@ jobs:
tox -e py$(echo ${{ matrix.python-version }} | tr -d .)-tests
- name: Test cli
run: |
tox -e py$(echo ${{ matrix.python-version }} | tr -d .)-cli
tox -e py$(echo ${{ matrix.python-version }} | tr -d .)-cli
- name: Check style
if: ${{ matrix.python-version == '3.8' }}
if: ${{ matrix.python-version == '3.13' }}
run: |
tox -e py$(echo ${{ matrix.python-version }} | tr -d .)-lint
tox -e copying
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.8' }}
uses: codecov/codecov-action@v1
if: ${{ matrix.python-version == '3.13' }}
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
- name: Build a source tarball
if: matrix.python-version == '3.8'
run: python setup.py sdist check --strict --metadata
- name: Build source distribution
if: matrix.python-version == '3.13'
run: |
pip install build
python -m build --sdist
9 changes: 4 additions & 5 deletions iotlabaggregator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#! /usr/bin/env python
# -*- coding:utf-8 -*-

# This file is a part of IoT-LAB aggregation-tools
# Copyright (C) 2015 INRIA (Contact: admin@iot-lab.info)
Expand All @@ -20,19 +19,19 @@
# The fact that you are presently reading this means that you have had
# knowledge of the CeCILL license and that you accept its terms.

""" Aggregator tools for IoT-Lab platform """
"""Aggregator tools for IoT-Lab platform"""

import sys
import logging
import sys

__version__ = '2.1.1'
__version__ = "2.1.1"


# Use loggers for all outputs to have the same config
LOG_FMT = logging.Formatter("%(created)f;%(message)s")

# error logger
LOGGER = logging.getLogger('iotlabaggregator')
LOGGER = logging.getLogger("iotlabaggregator")
_LOGGER = logging.StreamHandler(sys.stderr)
_LOGGER.setFormatter(LOG_FMT)
LOGGER.setLevel(logging.INFO)
Expand Down
56 changes: 33 additions & 23 deletions iotlabaggregator/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#! /usr/bin/env python
# -*- coding:utf-8 -*-

# This file is a part of IoT-LAB aggregation-tools
# Copyright (C) 2015 INRIA (Contact: admin@iot-lab.info)
Expand All @@ -21,13 +20,15 @@
# knowledge of the CeCILL license and that you accept its terms.


""" Common functions that may be required """
import os
"""Common functions that may be required"""

import itertools
import os

import iotlabcli
from iotlabcli import experiment
import iotlabcli.parser.common
import iotlabcli.parser.node
from iotlabcli import experiment

import iotlabaggregator

Expand Down Expand Up @@ -93,8 +94,8 @@ def extract_nodes(resources, hostname=None):
['m3-1', 'wsn430-4', 'a8-1']
"""
hostname = hostname or HOSTNAME
sites_nodes = [n for n in resources['items'] if n['site'] == hostname]
nodes = [n['network_address'].split('.')[0] for n in sites_nodes]
sites_nodes = [n for n in resources["items"] if n["site"] == hostname]
nodes = [n["network_address"].split(".")[0] for n in sites_nodes]
return nodes


Expand All @@ -105,11 +106,11 @@ def query_nodes(api, exp_id=None, nodes_list=None, hostname=None):
# -l grenoble,m3,1 -l grenoble,m3,5
# [['m3-1.grenoble.iot-lab.info'], ['m3-5.grenoble.iot-lab.info']]
nodes_list = frozenset(itertools.chain.from_iterable(nodes_list))
nodes_list = [n.split('.')[0] for n in nodes_list if hostname in n]
nodes_list = [n.split(".")[0] for n in nodes_list if hostname in n]
# try to get currently running experiment
if exp_id is None:
exp_id = iotlabcli.get_current_experiment(api)
exp_nodes = experiment.get_experiment(api, exp_id, 'nodes')
exp_nodes = experiment.get_experiment(api, exp_id, "nodes")
exp_nodes_list = extract_nodes(exp_nodes, hostname)
nodes = set(exp_nodes_list).intersection(nodes_list)
if nodes:
Expand All @@ -118,25 +119,34 @@ def query_nodes(api, exp_id=None, nodes_list=None, hostname=None):


def add_nodes_selection_parser(parser):
""" Add parser arguments for selecting nodes """
"""Add parser arguments for selecting nodes"""

iotlabcli.parser.common.add_auth_arguments(parser)
parser.add_argument('-v', '--version', action='version',
version=iotlabaggregator.__version__)
parser.add_argument(
"-v", "--version", action="version", version=iotlabaggregator.__version__
)
nodes_group = parser.add_argument_group(
description="By default, select currently running experiment nodes",
title="Nodes selection")

nodes_group.add_argument('-i', '--id', dest='experiment_id', type=int,
help='experiment id submission')
nodes_group.add_argument('-l', '--list', action='append',
type=iotlabcli.parser.common.nodes_list_from_str,
dest='nodes_list', help='nodes list')


def get_nodes_selection(username, password, experiment_id, nodes_list,
*_args, **_kwargs): # pylint:disable=unused-argument
""" Return the requested nodes from 'experiment_id', and 'nodes_list """
title="Nodes selection",
)

nodes_group.add_argument(
"-i", "--id", dest="experiment_id", type=int, help="experiment id submission"
)
nodes_group.add_argument(
"-l",
"--list",
action="append",
type=iotlabcli.parser.common.nodes_list_from_str,
dest="nodes_list",
help="nodes list",
)


def get_nodes_selection(
username, password, experiment_id, nodes_list, *_args, **_kwargs
): # pylint:disable=unused-argument
"""Return the requested nodes from 'experiment_id', and 'nodes_list"""
username, password = iotlabcli.get_user_credentials(username, password)
api = iotlabcli.Api(username, password)
with iotlabcli.parser.common.catch_missing_auth_cli():
Expand Down
Loading
Loading