mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2026-02-13 03:05:11 +00:00
Compare commits
6 Commits
v0.10.1
...
09c1e8ca73
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09c1e8ca73 | ||
|
|
e7b6b8190a | ||
|
|
933e84bf13 | ||
|
|
0b56378287 | ||
|
|
51b47596ce | ||
|
|
42e8befec4 |
@@ -1,67 +1,83 @@
|
|||||||
package:
|
package:
|
||||||
name: unilabos
|
name: unilabos
|
||||||
version: 0.10.1
|
version: 0.10.2
|
||||||
|
|
||||||
|
source:
|
||||||
|
path: ../unilabos
|
||||||
|
target_directory: unilabos
|
||||||
|
|
||||||
build:
|
build:
|
||||||
noarch: python
|
|
||||||
number: 0
|
|
||||||
script:
|
script:
|
||||||
- python -m pip install paho-mqtt opentrons_shared_data
|
- set PIP_NO_INDEX=
|
||||||
- python -m pip install git+https://github.com/Xuwznln/pylabrobot.git
|
- if: win
|
||||||
|
then:
|
||||||
|
- copy %RECIPE_DIR%\..\MANIFEST.in %SRC_DIR%
|
||||||
|
- copy %RECIPE_DIR%\..\setup.cfg %SRC_DIR%
|
||||||
|
- copy %RECIPE_DIR%\..\setup.py %SRC_DIR%
|
||||||
|
- python -m pip install %SRC_DIR%
|
||||||
|
- if: unix
|
||||||
|
then:
|
||||||
|
- cp $RECIPE_DIR/../MANIFEST.in $SRC_DIR
|
||||||
|
- cp $RECIPE_DIR/../setup.cfg $SRC_DIR
|
||||||
|
- cp $RECIPE_DIR/../setup.py $SRC_DIR
|
||||||
|
- python -m pip install $SRC_DIR
|
||||||
|
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
host:
|
host:
|
||||||
- python >=3.11
|
- python ==3.11.11
|
||||||
- pip
|
- pip
|
||||||
- setuptools
|
- setuptools
|
||||||
run:
|
run:
|
||||||
- conda-forge::python =3.11.11
|
- conda-forge::python ==3.11.11
|
||||||
- compilers
|
- compilers
|
||||||
- cmake
|
- cmake
|
||||||
|
- ninja
|
||||||
|
- if: unix
|
||||||
|
then:
|
||||||
- make
|
- make
|
||||||
- ninja
|
- sphinx
|
||||||
- sphinx
|
- sphinx_rtd_theme
|
||||||
- sphinx_rtd_theme
|
- numpy
|
||||||
- numpy
|
- scipy
|
||||||
- scipy
|
- pandas
|
||||||
- pandas
|
- networkx
|
||||||
- networkx
|
- matplotlib
|
||||||
- matplotlib
|
- pint
|
||||||
- pint
|
- pyserial
|
||||||
- pyserial
|
- pyusb
|
||||||
- pyusb
|
- pylibftdi
|
||||||
- pylibftdi
|
- pymodbus
|
||||||
- pymodbus
|
- python-can
|
||||||
- python-can
|
- pyvisa
|
||||||
- pyvisa
|
- opencv
|
||||||
- opencv
|
- pydantic
|
||||||
- pydantic
|
- fastapi
|
||||||
- fastapi
|
- uvicorn
|
||||||
- uvicorn
|
- gradio
|
||||||
- gradio
|
- flask
|
||||||
- flask
|
- websocket
|
||||||
- websocket
|
- ipython
|
||||||
- ipython
|
- jupyter
|
||||||
- jupyter
|
- jupyros
|
||||||
- jupyros
|
- colcon-common-extensions
|
||||||
- colcon-common-extensions
|
- robostack-staging::ros-humble-desktop-full
|
||||||
- robostack-staging::ros-humble-desktop-full
|
- robostack-staging::ros-humble-control-msgs
|
||||||
- robostack-staging::ros-humble-control-msgs
|
- robostack-staging::ros-humble-sensor-msgs
|
||||||
- robostack-staging::ros-humble-sensor-msgs
|
- robostack-staging::ros-humble-trajectory-msgs
|
||||||
- robostack-staging::ros-humble-trajectory-msgs
|
- ros-humble-navigation2
|
||||||
- ros-humble-navigation2
|
- ros-humble-ros2-control
|
||||||
- ros-humble-ros2-control
|
- ros-humble-robot-state-publisher
|
||||||
- ros-humble-robot-state-publisher
|
- ros-humble-joint-state-publisher
|
||||||
- ros-humble-joint-state-publisher
|
- ros-humble-rosbridge-server
|
||||||
- ros-humble-rosbridge-server
|
- ros-humble-cv-bridge
|
||||||
- ros-humble-cv-bridge
|
- ros-humble-tf2
|
||||||
- ros-humble-tf2
|
- ros-humble-moveit
|
||||||
- ros-humble-moveit
|
- ros-humble-moveit-servo
|
||||||
- ros-humble-moveit-servo
|
- ros-humble-simulation
|
||||||
- ros-humble-simulation
|
- ros-humble-tf-transformations
|
||||||
- ros-humble-tf-transformations
|
- transforms3d
|
||||||
- transforms3d
|
- uni-lab::ros-humble-unilabos-msgs
|
||||||
- uni-lab::ros-humble-unilabos-msgs
|
|
||||||
|
|
||||||
about:
|
about:
|
||||||
repository: https://github.com/dptech-corp/Uni-Lab-OS
|
repository: https://github.com/dptech-corp/Uni-Lab-OS
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package:
|
|
||||||
name: unilabos
|
|
||||||
version: "0.10.1"
|
|
||||||
|
|
||||||
source:
|
|
||||||
path: ../..
|
|
||||||
|
|
||||||
build:
|
|
||||||
noarch: python
|
|
||||||
script: |
|
|
||||||
{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vv
|
|
||||||
# {{ PYTHON }} clean_build_dir.py
|
|
||||||
|
|
||||||
requirements:
|
|
||||||
host:
|
|
||||||
- python
|
|
||||||
- pip
|
|
||||||
run:
|
|
||||||
- python
|
|
||||||
|
|
||||||
test:
|
|
||||||
imports:
|
|
||||||
- unilabos
|
|
||||||
9
.conda/scripts/post-link.bat
Normal file
9
.conda/scripts/post-link.bat
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
REM upgrade pip
|
||||||
|
"%PREFIX%\python.exe" -m pip install --upgrade pip
|
||||||
|
|
||||||
|
REM install extra deps
|
||||||
|
"%PREFIX%\python.exe" -m pip install paho-mqtt opentrons_shared_data
|
||||||
|
"%PREFIX%\python.exe" -m pip install git+https://github.com/Xuwznln/pylabrobot.git
|
||||||
9
.conda/scripts/post-link.sh
Normal file
9
.conda/scripts/post-link.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
# make sure pip is available
|
||||||
|
"$PREFIX/bin/python" -m pip install --upgrade pip
|
||||||
|
|
||||||
|
# install extra deps
|
||||||
|
"$PREFIX/bin/python" -m pip install paho-mqtt opentrons_shared_data
|
||||||
|
"$PREFIX/bin/python" -m pip install git+https://github.com/Xuwznln/pylabrobot.git
|
||||||
193
.github/workflows/multi-platform-build.yml
vendored
193
.github/workflows/multi-platform-build.yml
vendored
@@ -2,16 +2,21 @@ name: Multi-Platform Conda Build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, dev ]
|
branches: [main, dev]
|
||||||
tags: [ 'v*' ]
|
tags: ['v*']
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main, dev ]
|
branches: [main, dev]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
platforms:
|
platforms:
|
||||||
description: '选择构建平台 (逗号分隔): linux-64, osx-64, osx-arm64, win-64'
|
description: '选择构建平台 (逗号分隔): linux-64, osx-64, osx-arm64, win-64'
|
||||||
required: false
|
required: false
|
||||||
default: 'osx-arm64'
|
default: 'osx-arm64'
|
||||||
|
upload_to_anaconda:
|
||||||
|
description: '是否上传到Anaconda.org'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -19,18 +24,18 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
platform: linux-64
|
platform: linux-64
|
||||||
env_file: unilabos-linux-64.yaml
|
env_file: unilabos-linux-64.yaml
|
||||||
- os: macos-13 # Intel
|
- os: macos-13 # Intel
|
||||||
platform: osx-64
|
platform: osx-64
|
||||||
env_file: unilabos-osx-64.yaml
|
env_file: unilabos-osx-64.yaml
|
||||||
- os: macos-latest # ARM64
|
- os: macos-latest # ARM64
|
||||||
platform: osx-arm64
|
platform: osx-arm64
|
||||||
env_file: unilabos-osx-arm64.yaml
|
env_file: unilabos-osx-arm64.yaml
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
platform: win-64
|
platform: win-64
|
||||||
env_file: unilabos-win64.yaml
|
env_file: unilabos-win64.yaml
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
@@ -39,94 +44,88 @@ jobs:
|
|||||||
shell: bash -l {0}
|
shell: bash -l {0}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check if platform should be built
|
- name: Check if platform should be built
|
||||||
id: should_build
|
id: should_build
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
|
if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
|
||||||
echo "should_build=true" >> $GITHUB_OUTPUT
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
elif [[ -z "${{ github.event.inputs.platforms }}" ]]; then
|
elif [[ -z "${{ github.event.inputs.platforms }}" ]]; then
|
||||||
echo "should_build=true" >> $GITHUB_OUTPUT
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
elif [[ "${{ github.event.inputs.platforms }}" == *"${{ matrix.platform }}"* ]]; then
|
elif [[ "${{ github.event.inputs.platforms }}" == *"${{ matrix.platform }}"* ]]; then
|
||||||
echo "should_build=true" >> $GITHUB_OUTPUT
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "should_build=false" >> $GITHUB_OUTPUT
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Setup Miniconda
|
- name: Setup Miniconda
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
uses: conda-incubator/setup-miniconda@v3
|
uses: conda-incubator/setup-miniconda@v3
|
||||||
with:
|
with:
|
||||||
miniconda-version: "latest"
|
miniconda-version: 'latest'
|
||||||
channels: conda-forge,robostack-staging,defaults
|
channels: conda-forge,robostack-staging,defaults
|
||||||
channel-priority: strict
|
channel-priority: strict
|
||||||
activate-environment: build-env
|
activate-environment: build-env
|
||||||
auto-activate-base: false
|
auto-activate-base: false
|
||||||
auto-update-conda: false
|
auto-update-conda: false
|
||||||
show-channel-urls: true
|
show-channel-urls: true
|
||||||
|
|
||||||
- name: Install boa and build tools
|
- name: Install rattler-build and anaconda-client
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
conda install -c conda-forge boa conda-build
|
conda install -c conda-forge rattler-build anaconda-client
|
||||||
|
|
||||||
- name: Show environment info
|
- name: Show environment info
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
conda info
|
conda info
|
||||||
conda list | grep -E "(boa|conda-build)"
|
conda list | grep -E "(rattler-build|anaconda-client)"
|
||||||
echo "Platform: ${{ matrix.platform }}"
|
echo "Platform: ${{ matrix.platform }}"
|
||||||
echo "OS: ${{ matrix.os }}"
|
echo "OS: ${{ matrix.os }}"
|
||||||
|
|
||||||
- name: Build conda package
|
- name: Build conda package
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ matrix.platform }}" == "osx-arm64" ]]; then
|
if [[ "${{ matrix.platform }}" == "osx-arm64" ]]; then
|
||||||
boa build -m ./recipes/conda_build_config.yaml -m ./recipes/macos_sdk_config.yaml ./recipes/ros-humble-unilabos-msgs
|
rattler-build build -r ./recipes/msgs/recipe.yaml -c robostack -c robostack-staging -c conda-forge
|
||||||
else
|
else
|
||||||
boa build -m ./recipes/conda_build_config.yaml ./recipes/ros-humble-unilabos-msgs
|
rattler-build build -r ./recipes/msgs/recipe.yaml -c robostack -c robostack-staging -c conda-forge
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: List built packages
|
- name: List built packages
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
echo "Built packages in conda-bld:"
|
echo "Built packages in output directory:"
|
||||||
find $CONDA_PREFIX/conda-bld -name "*.tar.bz2" | head -10
|
find ./output -name "*.conda" | head -10
|
||||||
ls -la $CONDA_PREFIX/conda-bld/${{ matrix.platform }}/ || echo "${{ matrix.platform }} directory not found"
|
ls -la ./output/${{ matrix.platform }}/ || echo "${{ matrix.platform }} directory not found"
|
||||||
ls -la $CONDA_PREFIX/conda-bld/noarch/ || echo "noarch directory not found"
|
ls -la ./output/noarch/ || echo "noarch directory not found"
|
||||||
echo "CONDA_PREFIX: $CONDA_PREFIX"
|
echo "Output directory structure:"
|
||||||
echo "Full path would be: $CONDA_PREFIX/conda-bld/**/*.tar.bz2"
|
find ./output -type f -name "*.conda"
|
||||||
|
|
||||||
- name: Prepare artifacts for upload
|
- name: Prepare artifacts for upload
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ${{ runner.temp }}/conda-packages
|
mkdir -p conda-packages-temp
|
||||||
find $CONDA_PREFIX/conda-bld -name "*.tar.bz2" -exec cp {} ${{ runner.temp }}/conda-packages/ \;
|
find ./output -name "*.conda" -exec cp {} conda-packages-temp/ \;
|
||||||
echo "Copied files to temp directory:"
|
echo "Copied files to temp directory:"
|
||||||
ls -la ${{ runner.temp }}/conda-packages/
|
ls -la conda-packages-temp/
|
||||||
|
|
||||||
- name: Upload conda package artifacts
|
- name: Upload conda package artifacts
|
||||||
if: steps.should_build.outputs.should_build == 'true'
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: conda-package-${{ matrix.platform }}
|
name: conda-package-${{ matrix.platform }}
|
||||||
path: ${{ runner.temp }}/conda-packages
|
path: conda-packages-temp
|
||||||
if-no-files-found: warn
|
if-no-files-found: warn
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
- name: Create release assets (on tags)
|
- name: Upload to Anaconda.org (unilab organization)
|
||||||
if: steps.should_build.outputs.should_build == 'true' && startsWith(github.ref, 'refs/tags/')
|
if: steps.should_build.outputs.should_build == 'true' && github.event.inputs.upload_to_anaconda == 'true'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p release-assets
|
for package in $(find ./output -name "*.conda"); do
|
||||||
find $CONDA_PREFIX/conda-bld -name "*.tar.bz2" -exec cp {} release-assets/ \;
|
echo "Uploading $package to unilab organization..."
|
||||||
|
anaconda -t ${{ secrets.ANACONDA_API_TOKEN }} upload --user uni-lab --force "$package"
|
||||||
- name: Upload to release
|
done
|
||||||
if: steps.should_build.outputs.should_build == 'true' && startsWith(github.ref, 'refs/tags/')
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: release-assets/*
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
|
|||||||
124
.github/workflows/unilabos-conda-build.yml
vendored
Normal file
124
.github/workflows/unilabos-conda-build.yml
vendored
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
name: UniLabOS Conda Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main, dev]
|
||||||
|
tags: ['v*']
|
||||||
|
pull_request:
|
||||||
|
branches: [main, dev]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
platforms:
|
||||||
|
description: '选择构建平台 (逗号分隔): linux-64, osx-64, osx-arm64, win-64'
|
||||||
|
required: false
|
||||||
|
default: 'linux-64'
|
||||||
|
upload_to_anaconda:
|
||||||
|
description: '是否上传到Anaconda.org'
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
platform: linux-64
|
||||||
|
- os: macos-13 # Intel
|
||||||
|
platform: osx-64
|
||||||
|
- os: macos-latest # ARM64
|
||||||
|
platform: osx-arm64
|
||||||
|
- os: windows-latest
|
||||||
|
platform: win-64
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash -l {0}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Check if platform should be built
|
||||||
|
id: should_build
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then
|
||||||
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ -z "${{ github.event.inputs.platforms }}" ]]; then
|
||||||
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ "${{ github.event.inputs.platforms }}" == *"${{ matrix.platform }}"* ]]; then
|
||||||
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Setup Miniconda
|
||||||
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
|
uses: conda-incubator/setup-miniconda@v3
|
||||||
|
with:
|
||||||
|
miniconda-version: 'latest'
|
||||||
|
channels: conda-forge,robostack-staging,uni-lab,defaults
|
||||||
|
channel-priority: strict
|
||||||
|
activate-environment: build-env
|
||||||
|
auto-activate-base: false
|
||||||
|
auto-update-conda: false
|
||||||
|
show-channel-urls: true
|
||||||
|
|
||||||
|
- name: Install rattler-build and anaconda-client
|
||||||
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
|
run: |
|
||||||
|
conda install -c conda-forge rattler-build anaconda-client
|
||||||
|
|
||||||
|
- name: Show environment info
|
||||||
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
|
run: |
|
||||||
|
conda info
|
||||||
|
conda list | grep -E "(rattler-build|anaconda-client)"
|
||||||
|
echo "Platform: ${{ matrix.platform }}"
|
||||||
|
echo "OS: ${{ matrix.os }}"
|
||||||
|
echo "Building UniLabOS package"
|
||||||
|
|
||||||
|
- name: Build conda package
|
||||||
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
|
run: |
|
||||||
|
rattler-build build -r .conda/recipe.yaml -c uni-lab -c robostack-staging -c conda-forge
|
||||||
|
|
||||||
|
- name: List built packages
|
||||||
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
|
run: |
|
||||||
|
echo "Built packages in output directory:"
|
||||||
|
find ./output -name "*.conda" | head -10
|
||||||
|
ls -la ./output/${{ matrix.platform }}/ || echo "${{ matrix.platform }} directory not found"
|
||||||
|
ls -la ./output/noarch/ || echo "noarch directory not found"
|
||||||
|
echo "Output directory structure:"
|
||||||
|
find ./output -type f -name "*.conda"
|
||||||
|
|
||||||
|
- name: Prepare artifacts for upload
|
||||||
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
|
run: |
|
||||||
|
mkdir -p conda-packages-temp
|
||||||
|
find ./output -name "*.conda" -exec cp {} conda-packages-temp/ \;
|
||||||
|
echo "Copied files to temp directory:"
|
||||||
|
ls -la conda-packages-temp/
|
||||||
|
|
||||||
|
- name: Upload conda package artifacts
|
||||||
|
if: steps.should_build.outputs.should_build == 'true'
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: conda-package-unilabos-${{ matrix.platform }}
|
||||||
|
path: conda-packages-temp
|
||||||
|
if-no-files-found: warn
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
|
- name: Upload to Anaconda.org (uni-lab organization)
|
||||||
|
if: github.event.inputs.upload_to_anaconda == 'true'
|
||||||
|
run: |
|
||||||
|
for package in $(find ./output -name "*.conda"); do
|
||||||
|
echo "Uploading $package to uni-lab organization..."
|
||||||
|
anaconda -t ${{ secrets.ANACONDA_API_TOKEN }} upload --user uni-lab --force "$package"
|
||||||
|
done
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
recursive-include unilabos/registry *.yaml
|
recursive-include unilabos/registry *.yaml
|
||||||
recursive-include unilabos/app/static *
|
recursive-include unilabos/app/web/static *
|
||||||
recursive-include unilabos/app/templates *
|
recursive-include unilabos/app/web/templates *
|
||||||
recursive-include unilabos/device_mesh/devices *
|
recursive-include unilabos/device_mesh/devices *
|
||||||
recursive-include unilabos/device_mesh/resources *
|
recursive-include unilabos/device_mesh/resources *
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -34,20 +34,14 @@ Detailed documentation can be found at:
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
1. Configure Conda Environment
|
|
||||||
|
|
||||||
Uni-Lab-OS recommends using `mamba` for environment management. Choose the appropriate environment file for your operating system:
|
Uni-Lab-OS recommends using `mamba` for environment management. Choose the appropriate environment file for your operating system:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create new environment
|
# Create new environment
|
||||||
mamba create -n unilab unilab -c unilab -c robostack -c robostack-staging -c conda-forge
|
mamba create -n unilab uni-lab::unilabos -c robostack-staging -c conda-forge
|
||||||
|
|
||||||
# Or update existing environment
|
|
||||||
# Where `[YOUR_OS]` can be `win64`, `linux-64`, `osx-64`, or `osx-arm64`.
|
|
||||||
conda env update --file unilabos-[YOUR_OS].yml -n environment_name
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Install Uni-Lab-OS:
|
## Install Dev Uni-Lab-OS
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Clone the repository
|
# Clone the repository
|
||||||
|
|||||||
@@ -40,14 +40,10 @@ Uni-Lab-OS 建议使用 `mamba` 管理环境。根据您的操作系统选择适
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 创建新环境
|
# 创建新环境
|
||||||
mamba create -n unilab unilab -c unilab -c robostack -c robostack-staging -c conda-forge
|
mamba create -n unilab uni-lab::unilabos -c robostack-staging -c conda-forge
|
||||||
|
|
||||||
# 或更新现有环境
|
|
||||||
# 其中 `[YOUR_OS]` 可以是 `win64`, `linux-64`, `osx-64`, 或 `osx-arm64`。
|
|
||||||
conda env update --file unilabos-[YOUR_OS].yml -n 环境名
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 安装 Uni-Lab-OS:
|
2. 安装开发版Uni-Lab-OS:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 克隆仓库
|
# 克隆仓库
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
:: Generated by vinca http://github.com/RoboStack/vinca.
|
::Generated by vinca http://github.com/RoboStack/vinca.
|
||||||
:: DO NOT EDIT!
|
:: DO NOT EDIT!
|
||||||
setlocal EnableDelayedExpansion
|
setlocal EnableDelayedExpansion
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ set "CMAKE_GENERATOR=Visual Studio %VS_MAJOR% %VS_YEAR%"
|
|||||||
set "SP_DIR_FORWARDSLASHES=%SP_DIR:\=/%"
|
set "SP_DIR_FORWARDSLASHES=%SP_DIR:\=/%"
|
||||||
|
|
||||||
set PYTHON="%PREFIX%\python.exe"
|
set PYTHON="%PREFIX%\python.exe"
|
||||||
|
set PYTHON=%PYTHON:\=\\%
|
||||||
|
|
||||||
cmake ^
|
cmake ^
|
||||||
-G "%CMAKE_GENERATOR%" ^
|
-G "%CMAKE_GENERATOR%" ^
|
||||||
@@ -34,8 +35,10 @@ cmake ^
|
|||||||
-DCMAKE_OBJECT_PATH_MAX=255 ^
|
-DCMAKE_OBJECT_PATH_MAX=255 ^
|
||||||
-DPYTHON_INSTALL_DIR=%SP_DIR_FORWARDSLASHES% ^
|
-DPYTHON_INSTALL_DIR=%SP_DIR_FORWARDSLASHES% ^
|
||||||
--compile-no-warning-as-error ^
|
--compile-no-warning-as-error ^
|
||||||
%SRC_DIR%\%PKG_NAME%\src\work
|
%SRC_DIR%\src
|
||||||
|
|
||||||
if errorlevel 1 exit 1
|
if errorlevel 1 exit 1
|
||||||
|
|
||||||
cmake --build . --config Release --target install
|
cmake --build . --config Release --target install
|
||||||
|
|
||||||
if errorlevel 1 exit 1
|
if errorlevel 1 exit 1
|
||||||
@@ -24,7 +24,7 @@ echo "USING PKG_CONFIG_EXECUTABLE=${PKG_CONFIG_EXECUTABLE}"
|
|||||||
export ROS_PYTHON_VERSION=`$PYTHON_EXECUTABLE -c "import sys; print('%i.%i' % (sys.version_info[0:2]))"`
|
export ROS_PYTHON_VERSION=`$PYTHON_EXECUTABLE -c "import sys; print('%i.%i' % (sys.version_info[0:2]))"`
|
||||||
echo "Using Python ${ROS_PYTHON_VERSION}"
|
echo "Using Python ${ROS_PYTHON_VERSION}"
|
||||||
# Fix up SP_DIR which for some reason might contain a path to a wrong Python version
|
# Fix up SP_DIR which for some reason might contain a path to a wrong Python version
|
||||||
FIXED_SP_DIR=$(echo $SP_DIR | sed -E "s/python[0-9]+\.[0-9]+/python$ROS_PYTHON_VERSION/")
|
FIXED_SP_DIR=$($PYTHON_EXECUTABLE -c "import site; print(site.getsitepackages()[0])")
|
||||||
echo "Using site-package dir ${FIXED_SP_DIR}"
|
echo "Using site-package dir ${FIXED_SP_DIR}"
|
||||||
|
|
||||||
# see https://github.com/conda-forge/cross-python-feedstock/issues/24
|
# see https://github.com/conda-forge/cross-python-feedstock/issues/24
|
||||||
@@ -66,6 +66,6 @@ cmake \
|
|||||||
-DBUILD_TESTING=OFF \
|
-DBUILD_TESTING=OFF \
|
||||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=$OSX_DEPLOYMENT_TARGET \
|
-DCMAKE_OSX_DEPLOYMENT_TARGET=$OSX_DEPLOYMENT_TARGET \
|
||||||
--compile-no-warning-as-error \
|
--compile-no-warning-as-error \
|
||||||
$SRC_DIR/$PKG_NAME/src/work
|
$SRC_DIR/src
|
||||||
|
|
||||||
cmake --build . --config Release --target install
|
cmake --build . --config Release --target install
|
||||||
76
recipes/msgs/recipe.yaml
Normal file
76
recipes/msgs/recipe.yaml
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package:
|
||||||
|
name: ros-humble-unilabos-msgs
|
||||||
|
version: 0.10.2
|
||||||
|
source:
|
||||||
|
path: ../../unilabos_msgs
|
||||||
|
target_directory: src
|
||||||
|
|
||||||
|
build:
|
||||||
|
script:
|
||||||
|
- if: win
|
||||||
|
then:
|
||||||
|
- copy %RECIPE_DIR%\bld_ament_cmake.bat %SRC_DIR%
|
||||||
|
- call %SRC_DIR%\bld_ament_cmake.bat
|
||||||
|
- if: unix
|
||||||
|
then:
|
||||||
|
- cp $RECIPE_DIR/build_ament_cmake.sh $SRC_DIR
|
||||||
|
- bash $SRC_DIR/build_ament_cmake.sh
|
||||||
|
|
||||||
|
about:
|
||||||
|
repository: https://github.com/dptech-corp/Uni-Lab-OS
|
||||||
|
license: BSD-3-Clause
|
||||||
|
description: "ros-humble-unilabos-msgs is a package that provides message definitions for Uni-Lab-OS."
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
build:
|
||||||
|
- if: build_platform != target_platform
|
||||||
|
then:
|
||||||
|
- pkg-config
|
||||||
|
- python ==3.11.11
|
||||||
|
- cross-python_${{ target_platform }}
|
||||||
|
- numpy
|
||||||
|
- ${{ compiler('cxx') }}
|
||||||
|
- ${{ compiler('c') }}
|
||||||
|
- if: linux and x86_64
|
||||||
|
then:
|
||||||
|
- sysroot_linux-64 ==2.17
|
||||||
|
- ninja
|
||||||
|
- setuptools
|
||||||
|
- cython
|
||||||
|
- cmake
|
||||||
|
- if: unix
|
||||||
|
then:
|
||||||
|
- make
|
||||||
|
- coreutils
|
||||||
|
- if: osx
|
||||||
|
then:
|
||||||
|
- tapi
|
||||||
|
- if: win
|
||||||
|
then:
|
||||||
|
- vs2022_win-64
|
||||||
|
host:
|
||||||
|
- numpy
|
||||||
|
- pip
|
||||||
|
- if: build_platform == target_platform
|
||||||
|
then:
|
||||||
|
- pkg-config
|
||||||
|
- robostack-staging::ros-humble-action-msgs
|
||||||
|
- robostack-staging::ros-humble-ament-cmake
|
||||||
|
- robostack-staging::ros-humble-ament-lint-auto
|
||||||
|
- robostack-staging::ros-humble-ament-lint-common
|
||||||
|
- robostack-staging::ros-humble-ros-environment
|
||||||
|
- robostack-staging::ros-humble-ros-workspace
|
||||||
|
- robostack-staging::ros-humble-rosidl-default-generators
|
||||||
|
- robostack-staging::ros-humble-std-msgs
|
||||||
|
- robostack-staging::ros-humble-geometry-msgs
|
||||||
|
- robostack-staging::ros2-distro-mutex=0.6
|
||||||
|
run:
|
||||||
|
- robostack-staging::ros-humble-action-msgs
|
||||||
|
- robostack-staging::ros-humble-ros-workspace
|
||||||
|
- robostack-staging::ros-humble-rosidl-default-runtime
|
||||||
|
- robostack-staging::ros-humble-std-msgs
|
||||||
|
- robostack-staging::ros-humble-geometry-msgs
|
||||||
|
- robostack-staging::ros2-distro-mutex=0.6
|
||||||
|
- if: osx and x86_64
|
||||||
|
then:
|
||||||
|
- __osx >=${{ MACOSX_DEPLOYMENT_TARGET|default('10.14') }}
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package:
|
|
||||||
name: ros-humble-unilabos-msgs
|
|
||||||
version: 0.10.1
|
|
||||||
source:
|
|
||||||
path: ../../unilabos_msgs
|
|
||||||
folder: ros-humble-unilabos-msgs/src/work
|
|
||||||
|
|
||||||
build:
|
|
||||||
script:
|
|
||||||
sel(win): bld_ament_cmake.bat
|
|
||||||
sel(unix): build_ament_cmake.sh
|
|
||||||
number: 5
|
|
||||||
about:
|
|
||||||
home: https://www.ros.org/
|
|
||||||
license: BSD-3-Clause
|
|
||||||
summary: |
|
|
||||||
Robot Operating System
|
|
||||||
|
|
||||||
extra:
|
|
||||||
recipe-maintainers:
|
|
||||||
- ros-forge
|
|
||||||
|
|
||||||
requirements:
|
|
||||||
build:
|
|
||||||
- "{{ compiler('cxx') }}"
|
|
||||||
- "{{ compiler('c') }}"
|
|
||||||
- sel(linux64): sysroot_linux-64 2.17
|
|
||||||
- ninja
|
|
||||||
- setuptools
|
|
||||||
- sel(unix): make
|
|
||||||
- sel(unix): coreutils
|
|
||||||
- sel(osx): tapi
|
|
||||||
- sel(build_platform != target_platform): pkg-config
|
|
||||||
- cmake
|
|
||||||
- cython
|
|
||||||
- sel(win): vs2022_win-64
|
|
||||||
- sel(build_platform != target_platform): python
|
|
||||||
- sel(build_platform != target_platform): cross-python_{{ target_platform }}
|
|
||||||
- sel(build_platform != target_platform): numpy
|
|
||||||
host:
|
|
||||||
- numpy
|
|
||||||
- pip
|
|
||||||
- sel(build_platform == target_platform): pkg-config
|
|
||||||
- robostack-staging::ros-humble-action-msgs
|
|
||||||
- robostack-staging::ros-humble-ament-cmake
|
|
||||||
- robostack-staging::ros-humble-ament-lint-auto
|
|
||||||
- robostack-staging::ros-humble-ament-lint-common
|
|
||||||
- robostack-staging::ros-humble-ros-environment
|
|
||||||
- robostack-staging::ros-humble-ros-workspace
|
|
||||||
- robostack-staging::ros-humble-rosidl-default-generators
|
|
||||||
- robostack-staging::ros-humble-std-msgs
|
|
||||||
- robostack-staging::ros-humble-geometry-msgs
|
|
||||||
- robostack-staging::ros2-distro-mutex=0.6.*
|
|
||||||
run:
|
|
||||||
- robostack-staging::ros-humble-action-msgs
|
|
||||||
- robostack-staging::ros-humble-ros-workspace
|
|
||||||
- robostack-staging::ros-humble-rosidl-default-runtime
|
|
||||||
- robostack-staging::ros-humble-std-msgs
|
|
||||||
- robostack-staging::ros-humble-geometry-msgs
|
|
||||||
- robostack-staging::ros2-distro-mutex=0.6.*
|
|
||||||
- sel(osx and x86_64): __osx >={{ MACOSX_DEPLOYMENT_TARGET|default('10.14') }}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package:
|
package:
|
||||||
name: unilabos
|
name: unilabos
|
||||||
version: "0.10.1"
|
version: "0.10.2"
|
||||||
|
|
||||||
source:
|
source:
|
||||||
path: ../..
|
path: ../..
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -4,7 +4,7 @@ package_name = 'unilabos'
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=package_name,
|
name=package_name,
|
||||||
version='0.10.1',
|
version='0.10.2',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=['setuptools'],
|
install_requires=['setuptools'],
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from unilabos.utils.banner_print import print_status, print_unilab_banner
|
|||||||
|
|
||||||
def load_config_from_file(config_path, override_labid=None):
|
def load_config_from_file(config_path, override_labid=None):
|
||||||
if config_path is None:
|
if config_path is None:
|
||||||
config_path = os.environ.get("UNILABOS.BASICCONFIG.CONFIG_PATH", None)
|
config_path = os.environ.get("UNILABOS_BASICCONFIG_CONFIG_PATH", None)
|
||||||
if config_path:
|
if config_path:
|
||||||
if not os.path.exists(config_path):
|
if not os.path.exists(config_path):
|
||||||
print_status(f"配置文件 {config_path} 不存在", "error")
|
print_status(f"配置文件 {config_path} 不存在", "error")
|
||||||
@@ -43,10 +43,11 @@ def convert_argv_dashes_to_underscores(args: argparse.ArgumentParser):
|
|||||||
for i, arg in enumerate(sys.argv):
|
for i, arg in enumerate(sys.argv):
|
||||||
for option_string in option_strings:
|
for option_string in option_strings:
|
||||||
if arg.startswith(option_string):
|
if arg.startswith(option_string):
|
||||||
new_arg = arg[:2] + arg[2:len(option_string)].replace("-", "_") + arg[len(option_string):]
|
new_arg = arg[:2] + arg[2 : len(option_string)].replace("-", "_") + arg[len(option_string) :]
|
||||||
sys.argv[i] = new_arg
|
sys.argv[i] = new_arg
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
"""解析命令行参数"""
|
"""解析命令行参数"""
|
||||||
parser = argparse.ArgumentParser(description="Start Uni-Lab Edge server.")
|
parser = argparse.ArgumentParser(description="Start Uni-Lab Edge server.")
|
||||||
@@ -126,7 +127,12 @@ def parse_args():
|
|||||||
"--labid",
|
"--labid",
|
||||||
type=str,
|
type=str,
|
||||||
default="",
|
default="",
|
||||||
help="实验室唯一ID,也可通过环境变量 UNILABOS.MQCONFIG.LABID 设置或传入--config设置",
|
help="实验室唯一ID,也可通过环境变量 UNILABOS_MQCONFIG_LABID 设置或传入--config设置",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--skip_env_check",
|
||||||
|
action="store_true",
|
||||||
|
help="跳过启动时的环境依赖检查",
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@@ -138,31 +144,53 @@ def main():
|
|||||||
convert_argv_dashes_to_underscores(args)
|
convert_argv_dashes_to_underscores(args)
|
||||||
args_dict = vars(args.parse_args())
|
args_dict = vars(args.parse_args())
|
||||||
|
|
||||||
|
# 环境检查 - 检查并自动安装必需的包 (可选)
|
||||||
|
if not args_dict.get("skip_env_check", False):
|
||||||
|
from unilabos.utils.environment_check import check_environment
|
||||||
|
|
||||||
|
print_status("正在进行环境依赖检查...", "info")
|
||||||
|
if not check_environment(auto_install=True):
|
||||||
|
print_status("环境检查失败,程序退出", "error")
|
||||||
|
os._exit(1)
|
||||||
|
else:
|
||||||
|
print_status("跳过环境依赖检查", "warning")
|
||||||
|
|
||||||
# 加载配置文件,优先加载config,然后从env读取
|
# 加载配置文件,优先加载config,然后从env读取
|
||||||
config_path = args_dict.get("config")
|
config_path = args_dict.get("config")
|
||||||
working_dir = os.path.abspath(os.path.join(os.getcwd(), "unilabos_data"))
|
if os.getcwd().endswith("unilabos_data"):
|
||||||
if not config_path and (not os.path.exists(working_dir) or not os.path.exists(os.path.join(working_dir, "local_config.py"))):
|
working_dir = os.path.abspath(os.getcwd())
|
||||||
print_status(f"当前未指定config路径,非第一次使用请通过 --config 传入 local_config.py 文件路径", "info")
|
else:
|
||||||
print_status(f"您是否为第一次使用?并将当前文件路径 {working_dir} 作为工作目录? (Y/n)", "info")
|
working_dir = os.path.abspath(os.path.join(os.getcwd(), "unilabos_data"))
|
||||||
|
if args_dict.get("working_dir"):
|
||||||
|
working_dir = args_dict.get("working_dir")
|
||||||
|
if config_path and not os.path.exists(config_path):
|
||||||
|
config_path = os.path.join(working_dir, "local_config.py")
|
||||||
|
if not os.path.exists(config_path):
|
||||||
|
print_status(
|
||||||
|
f"当前工作目录 {working_dir} 未找到local_config.py,请通过 --config 传入 local_config.py 文件路径",
|
||||||
|
"error",
|
||||||
|
)
|
||||||
|
os._exit(1)
|
||||||
|
elif os.path.exists(working_dir) and os.path.exists(os.path.join(working_dir, "local_config.py")):
|
||||||
|
config_path = os.path.join(working_dir, "local_config.py")
|
||||||
|
elif not config_path and (
|
||||||
|
not os.path.exists(working_dir) or not os.path.exists(os.path.join(working_dir, "local_config.py"))
|
||||||
|
):
|
||||||
|
print_status(f"未指定config路径,可通过 --config 传入 local_config.py 文件路径", "info")
|
||||||
|
print_status(f"您是否为第一次使用?并将当前路径 {working_dir} 作为工作目录? (Y/n)", "info")
|
||||||
if input() != "n":
|
if input() != "n":
|
||||||
os.makedirs(working_dir, exist_ok=True)
|
os.makedirs(working_dir, exist_ok=True)
|
||||||
config_path = os.path.join(working_dir, "local_config.py")
|
config_path = os.path.join(working_dir, "local_config.py")
|
||||||
shutil.copy(os.path.join(os.path.dirname(os.path.dirname(__file__)), "config", "example_config.py"), config_path)
|
shutil.copy(
|
||||||
|
os.path.join(os.path.dirname(os.path.dirname(__file__)), "config", "example_config.py"), config_path
|
||||||
|
)
|
||||||
print_status(f"已创建 local_config.py 路径: {config_path}", "info")
|
print_status(f"已创建 local_config.py 路径: {config_path}", "info")
|
||||||
print_status(f"请在文件夹中配置lab_id,放入下载的CA.crt、lab.crt、lab.key重新启动本程序", "info")
|
print_status(f"请在文件夹中配置lab_id,放入下载的CA.crt、lab.crt、lab.key重新启动本程序", "info")
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
else:
|
else:
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
else:
|
|
||||||
working_dir = args_dict.get("working_dir") or os.path.abspath(os.path.join(os.getcwd(), "unilabos_data"))
|
|
||||||
if working_dir:
|
|
||||||
if config_path and not os.path.exists(config_path):
|
|
||||||
config_path = os.path.join(working_dir, "local_config.py")
|
|
||||||
if not os.path.exists(config_path):
|
|
||||||
print_status(f"当前工作目录 {working_dir} 未找到local_config.py,请通过 --config 传入 local_config.py 文件路径", "error")
|
|
||||||
os._exit(1)
|
|
||||||
print_status(f"当前工作目录为 {working_dir}", "info")
|
|
||||||
# 加载配置文件
|
# 加载配置文件
|
||||||
|
print_status(f"当前工作目录为 {working_dir}", "info")
|
||||||
load_config_from_file(config_path, args_dict["labid"])
|
load_config_from_file(config_path, args_dict["labid"])
|
||||||
|
|
||||||
# 设置BasicConfig参数
|
# 设置BasicConfig参数
|
||||||
@@ -204,10 +232,11 @@ def main():
|
|||||||
print_status("联网获取设备加载文件成功", "info")
|
print_status("联网获取设备加载文件成功", "info")
|
||||||
graph, data = read_node_link_json(request_startup_json)
|
graph, data = read_node_link_json(request_startup_json)
|
||||||
else:
|
else:
|
||||||
if args_dict["graph"].endswith(".json"):
|
file_path = args_dict["graph"]
|
||||||
graph, data = read_node_link_json(args_dict["graph"])
|
if file_path.endswith(".json"):
|
||||||
|
graph, data = read_node_link_json(file_path)
|
||||||
else:
|
else:
|
||||||
graph, data = read_graphml(args_dict["graph"])
|
graph, data = read_graphml(file_path)
|
||||||
import unilabos.resources.graphio as graph_res
|
import unilabos.resources.graphio as graph_res
|
||||||
|
|
||||||
graph_res.physical_setup_graph = graph
|
graph_res.physical_setup_graph = graph
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ HTTP客户端模块
|
|||||||
提供与远程服务器通信的客户端功能,只有host需要用
|
提供与远程服务器通信的客户端功能,只有host需要用
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
from typing import List, Dict, Any, Optional
|
from typing import List, Dict, Any, Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from unilabos.utils.log import info
|
from unilabos.utils.log import info
|
||||||
from unilabos.config.config import MQConfig, HTTPConfig
|
from unilabos.config.config import MQConfig, HTTPConfig, BasicConfig
|
||||||
from unilabos.utils import logger
|
from unilabos.utils import logger
|
||||||
|
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ class HTTPClient:
|
|||||||
logger.error(f"请求启动配置失败: {response.status_code}, {response.text}")
|
logger.error(f"请求启动配置失败: {response.status_code}, {response.text}")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open("startup_config.json", "w", encoding="utf-8") as f:
|
with open(os.path.join(BasicConfig.working_dir, "startup_config.json"), "w", encoding="utf-8") as f:
|
||||||
f.write(response.text)
|
f.write(response.text)
|
||||||
target_dict = json.loads(response.text)
|
target_dict = json.loads(response.text)
|
||||||
if "data" in target_dict:
|
if "data" in target_dict:
|
||||||
|
|||||||
@@ -109,13 +109,13 @@ def _update_config_from_module(module, override_labid: str):
|
|||||||
|
|
||||||
|
|
||||||
def _update_config_from_env():
|
def _update_config_from_env():
|
||||||
prefix = "UNILABOS."
|
prefix = "UNILABOS_"
|
||||||
for env_key, env_value in os.environ.items():
|
for env_key, env_value in os.environ.items():
|
||||||
if not env_key.startswith(prefix):
|
if not env_key.startswith(prefix):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
key_path = env_key[len(prefix):] # Remove UNILAB_ prefix
|
key_path = env_key[len(prefix):] # Remove UNILAB_ prefix
|
||||||
class_field = key_path.upper().split(".", 1)
|
class_field = key_path.upper().split("_", 1)
|
||||||
if len(class_field) != 2:
|
if len(class_field) != 2:
|
||||||
logger.warning(f"[ENV] 环境变量格式不正确:{env_key}")
|
logger.warning(f"[ENV] 环境变量格式不正确:{env_key}")
|
||||||
continue
|
continue
|
||||||
@@ -163,12 +163,12 @@ def _update_config_from_env():
|
|||||||
def load_config(config_path=None, override_labid=None):
|
def load_config(config_path=None, override_labid=None):
|
||||||
# 如果提供了配置文件路径,从该文件导入配置
|
# 如果提供了配置文件路径,从该文件导入配置
|
||||||
if config_path:
|
if config_path:
|
||||||
_update_config_from_env() # 允许config_path被env设定后读取
|
env_config_path = os.environ.get("UNILABOS_BASICCONFIG_CONFIG_PATH")
|
||||||
|
config_path = env_config_path if env_config_path else config_path
|
||||||
BasicConfig.config_path = os.path.abspath(os.path.dirname(config_path))
|
BasicConfig.config_path = os.path.abspath(os.path.dirname(config_path))
|
||||||
if not os.path.exists(config_path):
|
if not os.path.exists(config_path):
|
||||||
logger.error(f"[ENV] 配置文件 {config_path} 不存在")
|
logger.error(f"[ENV] 配置文件 {config_path} 不存在")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
module_name = "lab_" + os.path.basename(config_path).replace(".py", "")
|
module_name = "lab_" + os.path.basename(config_path).replace(".py", "")
|
||||||
spec = importlib.util.spec_from_file_location(module_name, config_path)
|
spec = importlib.util.spec_from_file_location(module_name, config_path)
|
||||||
@@ -179,6 +179,7 @@ def load_config(config_path=None, override_labid=None):
|
|||||||
spec.loader.exec_module(module) # type: ignore
|
spec.loader.exec_module(module) # type: ignore
|
||||||
_update_config_from_module(module, override_labid)
|
_update_config_from_module(module, override_labid)
|
||||||
logger.info(f"[ENV] 配置文件 {config_path} 加载成功")
|
logger.info(f"[ENV] 配置文件 {config_path} 加载成功")
|
||||||
|
_update_config_from_env()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"[ENV] 加载配置文件 {config_path} 失败")
|
logger.error(f"[ENV] 加载配置文件 {config_path} 失败")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ class MQConfig:
|
|||||||
broker_url = ""
|
broker_url = ""
|
||||||
port = 1883
|
port = 1883
|
||||||
|
|
||||||
ca_file = "CA.crt"
|
ca_file = "./CA.crt"
|
||||||
cert_file = "lab.crt"
|
cert_file = "./lab.crt"
|
||||||
key_file = "lab.key"
|
key_file = "./lab.key"
|
||||||
|
|
||||||
# HTTP配置
|
# HTTP配置
|
||||||
class HTTPConfig:
|
class HTTPConfig:
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
from unilabos.utils.log import logger
|
from unilabos.utils.log import logger
|
||||||
|
from unilabos.utils.environment_check import check_environment, EnvironmentChecker
|
||||||
|
|
||||||
# 确保日志配置在导入utils包时自动应用
|
# 确保日志配置在导入utils包时自动应用
|
||||||
# 这样任何导入utils包或其子模块的代码都会自动配置好日志
|
# 这样任何导入utils包或其子模块的代码都会自动配置好日志
|
||||||
|
|
||||||
# 导出logger,使其可以通过from unilabos.utils import logger直接导入
|
# 导出logger和环境检查工具,使其可以直接导入
|
||||||
__all__ = ['logger']
|
__all__ = ["logger", "check_environment", "EnvironmentChecker"]
|
||||||
|
|||||||
187
unilabos/utils/environment_check.py
Normal file
187
unilabos/utils/environment_check.py
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
"""
|
||||||
|
环境检查模块
|
||||||
|
用于检查并自动安装 UniLabOS 运行所需的 Python 包
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import importlib
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from .banner_print import print_status
|
||||||
|
|
||||||
|
|
||||||
|
class EnvironmentChecker:
|
||||||
|
"""环境检查器"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
# 定义必需的包及其安装名称的映射
|
||||||
|
self.required_packages = {
|
||||||
|
# 包导入名 : pip安装名
|
||||||
|
"paho.mqtt": "paho-mqtt",
|
||||||
|
"opentrons_shared_data": "opentrons_shared_data",
|
||||||
|
}
|
||||||
|
|
||||||
|
# 特殊安装包(需要特殊处理的包)
|
||||||
|
self.special_packages = {"pylabrobot": "git+https://github.com/Xuwznln/pylabrobot.git"}
|
||||||
|
|
||||||
|
self.missing_packages = []
|
||||||
|
self.failed_installs = []
|
||||||
|
|
||||||
|
def check_package_installed(self, package_name: str) -> bool:
|
||||||
|
"""检查包是否已安装"""
|
||||||
|
try:
|
||||||
|
importlib.import_module(package_name)
|
||||||
|
return True
|
||||||
|
except ImportError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def install_package(self, package_name: str, pip_name: str) -> bool:
|
||||||
|
"""安装包"""
|
||||||
|
try:
|
||||||
|
print_status(f"正在安装 {package_name} ({pip_name})...", "info")
|
||||||
|
|
||||||
|
# 构建安装命令
|
||||||
|
cmd = [sys.executable, "-m", "pip", "install", pip_name]
|
||||||
|
|
||||||
|
# 执行安装
|
||||||
|
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300) # 5分钟超时
|
||||||
|
|
||||||
|
if result.returncode == 0:
|
||||||
|
print_status(f"✅ {package_name} 安装成功", "success")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print_status(f"❌ {package_name} 安装失败: {result.stderr}", "error")
|
||||||
|
return False
|
||||||
|
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
print_status(f"❌ {package_name} 安装超时", "error")
|
||||||
|
return False
|
||||||
|
except Exception as e:
|
||||||
|
print_status(f"❌ {package_name} 安装异常: {str(e)}", "error")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def check_all_packages(self) -> bool:
|
||||||
|
"""检查所有必需的包"""
|
||||||
|
print_status("开始检查环境依赖...", "info")
|
||||||
|
|
||||||
|
# 检查常规包
|
||||||
|
for import_name, pip_name in self.required_packages.items():
|
||||||
|
if not self.check_package_installed(import_name):
|
||||||
|
self.missing_packages.append((import_name, pip_name))
|
||||||
|
|
||||||
|
# 检查特殊包
|
||||||
|
for package_name, install_url in self.special_packages.items():
|
||||||
|
if not self.check_package_installed(package_name):
|
||||||
|
self.missing_packages.append((package_name, install_url))
|
||||||
|
|
||||||
|
if not self.missing_packages:
|
||||||
|
print_status("✅ 所有依赖包检查完成,环境正常", "success")
|
||||||
|
return True
|
||||||
|
|
||||||
|
print_status(f"发现 {len(self.missing_packages)} 个缺失的包", "warning")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def install_missing_packages(self, auto_install: bool = True) -> bool:
|
||||||
|
"""安装缺失的包"""
|
||||||
|
if not self.missing_packages:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if not auto_install:
|
||||||
|
print_status("缺失以下包:", "warning")
|
||||||
|
for import_name, pip_name in self.missing_packages:
|
||||||
|
print_status(f" - {import_name} (pip install {pip_name})", "warning")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print_status(f"开始自动安装 {len(self.missing_packages)} 个缺失的包...", "info")
|
||||||
|
|
||||||
|
success_count = 0
|
||||||
|
for import_name, pip_name in self.missing_packages:
|
||||||
|
if self.install_package(import_name, pip_name):
|
||||||
|
success_count += 1
|
||||||
|
else:
|
||||||
|
self.failed_installs.append((import_name, pip_name))
|
||||||
|
|
||||||
|
if self.failed_installs:
|
||||||
|
print_status(f"有 {len(self.failed_installs)} 个包安装失败:", "error")
|
||||||
|
for import_name, pip_name in self.failed_installs:
|
||||||
|
print_status(f" - {import_name} (pip install {pip_name})", "error")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print_status(f"✅ 成功安装 {success_count} 个包", "success")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def verify_installation(self) -> bool:
|
||||||
|
"""验证安装结果"""
|
||||||
|
if not self.missing_packages:
|
||||||
|
return True
|
||||||
|
|
||||||
|
print_status("验证安装结果...", "info")
|
||||||
|
|
||||||
|
failed_verification = []
|
||||||
|
for import_name, pip_name in self.missing_packages:
|
||||||
|
if not self.check_package_installed(import_name):
|
||||||
|
failed_verification.append((import_name, pip_name))
|
||||||
|
|
||||||
|
if failed_verification:
|
||||||
|
print_status(f"有 {len(failed_verification)} 个包验证失败:", "error")
|
||||||
|
for import_name, pip_name in failed_verification:
|
||||||
|
print_status(f" - {import_name}", "error")
|
||||||
|
return False
|
||||||
|
|
||||||
|
print_status("✅ 所有包验证通过", "success")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def check_environment(auto_install: bool = True, show_details: bool = True) -> bool:
|
||||||
|
"""
|
||||||
|
检查环境并自动安装缺失的包
|
||||||
|
|
||||||
|
Args:
|
||||||
|
auto_install: 是否自动安装缺失的包
|
||||||
|
show_details: 是否显示详细信息
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: 环境检查是否通过
|
||||||
|
"""
|
||||||
|
checker = EnvironmentChecker()
|
||||||
|
|
||||||
|
# 检查包
|
||||||
|
if checker.check_all_packages():
|
||||||
|
return True
|
||||||
|
|
||||||
|
# 安装缺失的包
|
||||||
|
if not checker.install_missing_packages(auto_install):
|
||||||
|
if show_details:
|
||||||
|
print_status("请手动安装缺失的包后重新启动程序", "error")
|
||||||
|
return False
|
||||||
|
|
||||||
|
# 验证安装
|
||||||
|
if not checker.verify_installation():
|
||||||
|
if show_details:
|
||||||
|
print_status("安装验证失败,请检查网络连接或手动安装", "error")
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# 命令行参数解析
|
||||||
|
parser = argparse.ArgumentParser(description="UniLabOS 环境依赖检查工具")
|
||||||
|
parser.add_argument("--no-auto-install", action="store_true", help="仅检查环境,不自动安装缺失的包")
|
||||||
|
parser.add_argument("--silent", action="store_true", help="静默模式,不显示详细信息")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# 执行环境检查
|
||||||
|
auto_install = not args.no_auto_install
|
||||||
|
show_details = not args.silent
|
||||||
|
|
||||||
|
success = check_environment(auto_install=auto_install, show_details=show_details)
|
||||||
|
|
||||||
|
if not success:
|
||||||
|
if show_details:
|
||||||
|
print_status("环境检查失败", "error")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
if show_details:
|
||||||
|
print_status("环境检查完成", "success")
|
||||||
@@ -144,11 +144,29 @@ class ColoredFormatter(logging.Formatter):
|
|||||||
|
|
||||||
|
|
||||||
# 配置日志处理器
|
# 配置日志处理器
|
||||||
def configure_logger():
|
def configure_logger(loglevel=None):
|
||||||
"""配置日志记录器"""
|
"""配置日志记录器
|
||||||
|
|
||||||
|
Args:
|
||||||
|
loglevel: 日志级别,可以是字符串('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL')
|
||||||
|
或logging模块的常量(如logging.DEBUG)
|
||||||
|
"""
|
||||||
# 获取根日志记录器
|
# 获取根日志记录器
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
root_logger.setLevel(logging.DEBUG) # 修改为DEBUG以显示所有级别
|
|
||||||
|
# 设置日志级别
|
||||||
|
if loglevel is not None:
|
||||||
|
if isinstance(loglevel, str):
|
||||||
|
# 将字符串转换为logging级别
|
||||||
|
numeric_level = getattr(logging, loglevel.upper(), None)
|
||||||
|
if not isinstance(numeric_level, int):
|
||||||
|
print(f"警告: 无效的日志级别 '{loglevel}',使用默认级别 DEBUG")
|
||||||
|
numeric_level = logging.DEBUG
|
||||||
|
else:
|
||||||
|
numeric_level = loglevel
|
||||||
|
root_logger.setLevel(numeric_level)
|
||||||
|
else:
|
||||||
|
root_logger.setLevel(logging.DEBUG) # 默认级别
|
||||||
|
|
||||||
# 移除已存在的处理器
|
# 移除已存在的处理器
|
||||||
for handler in root_logger.handlers[:]:
|
for handler in root_logger.handlers[:]:
|
||||||
@@ -156,7 +174,7 @@ def configure_logger():
|
|||||||
|
|
||||||
# 创建控制台处理器
|
# 创建控制台处理器
|
||||||
console_handler = logging.StreamHandler()
|
console_handler = logging.StreamHandler()
|
||||||
console_handler.setLevel(logging.DEBUG) # 修改为DEBUG以显示所有级别
|
console_handler.setLevel(root_logger.level) # 使用与根记录器相同的级别
|
||||||
|
|
||||||
# 使用自定义的颜色格式化器
|
# 使用自定义的颜色格式化器
|
||||||
color_formatter = ColoredFormatter()
|
color_formatter = ColoredFormatter()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
<package format="3">
|
<package format="3">
|
||||||
<name>unilabos_msgs</name>
|
<name>unilabos_msgs</name>
|
||||||
<version>0.0.5</version>
|
<version>0.10.2</version>
|
||||||
<description>ROS2 Messages package for unilabos devices</description>
|
<description>ROS2 Messages package for unilabos devices</description>
|
||||||
<maintainer email="changjh@pku.edu.cn">Junhan Chang</maintainer>
|
<maintainer email="changjh@pku.edu.cn">Junhan Chang</maintainer>
|
||||||
<license>MIT</license>
|
<license>MIT</license>
|
||||||
|
|||||||
Reference in New Issue
Block a user