Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Memory storage #5

Merged
merged 33 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c27df9a
Merge pull request #4 from H-IAAC/dev
EltonCN Nov 28, 2024
bdc45bc
MS type check
EltonCN Nov 28, 2024
edc19f3
MS logging
EltonCN Nov 28, 2024
5cbcfca
MS logical time
EltonCN Dec 1, 2024
65ddd97
MS tests
EltonCN Dec 1, 2024
952245e
Tests CI fix
EltonCN Dec 1, 2024
ad9a56d
Update test.yml
EltonCN Dec 1, 2024
04ae5d8
Test: fix Redis port
EltonCN Dec 1, 2024
3e4bc99
Tests CI OS check
EltonCN Dec 1, 2024
2a17a4a
Update test.yml
EltonCN Dec 1, 2024
acb1e58
Test reusable test workflow
EltonCN Dec 1, 2024
b95149b
Update test.yml
EltonCN Dec 1, 2024
8194260
Update test.yml
EltonCN Dec 1, 2024
2f70a76
Update test.yml
EltonCN Dec 1, 2024
72958d7
Try composite action
EltonCN Dec 1, 2024
0f0b517
Update action.yml
EltonCN Dec 1, 2024
acce3a7
Update action.yml
EltonCN Dec 1, 2024
abda3d2
Fix inner action and OS specific test
EltonCN Dec 1, 2024
45ffbbd
Update action.yml
EltonCN Dec 1, 2024
c884418
Fix tests
EltonCN Dec 1, 2024
7e0a9b5
Ignore dev folder in tests
EltonCN Dec 1, 2024
d5c4da5
Supports Redis client args
EltonCN Dec 2, 2024
0588cd5
Redis args test
EltonCN Dec 2, 2024
abb63f2
MS documentation
EltonCN Dec 2, 2024
ce45936
MS documentation
EltonCN Dec 2, 2024
d15a242
Memory Storage example
EltonCN Dec 2, 2024
64b2f3d
Memory Storage example test
EltonCN Dec 2, 2024
cfc55ab
Test Lamport Time
EltonCN Dec 2, 2024
df47552
Fix tests MS
EltonCN Dec 2, 2024
39428e9
MS example test skip if no Redis
EltonCN Dec 4, 2024
f8ebb62
Test memory encoder
EltonCN Dec 4, 2024
30a8a93
Typo fix
EltonCN Dec 4, 2024
f91088d
Test with MS Java
EltonCN Dec 9, 2024
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
66 changes: 38 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,56 @@ on:
branches: [ dev, main ]

jobs:
test:

runs-on: ${{ matrix.os }}
test-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]

services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install pytest
python3 -m pip install pytest-cov
python3 -m pip install -e .[tests,gym]
- uses: actions/checkout@v2

- uses: ./.github/workflows/test_inner
with:
os: ubuntu-latest
python-version: ${{ matrix.python-version }}

- name: Tests
run: |
pytest --cov=cst_python --cov-report json
shell: bash

- if: ${{matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'}}
name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage_report
path: coverage.json
test-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2

- uses: ./.github/workflows/test_inner
with:
os: windows-latest
python-version: ${{ matrix.python-version }}

coverage-check:
runs-on: ubuntu-latest
needs:
- test
- test-linux

steps:
- uses: actions/checkout@v2
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/test_inner/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Test inner

inputs:
os:
required: true
type: string
python-version:
required: true
type: string

runs:
using: composite
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{inputs.python-version}}
uses: actions/setup-python@v2
with:
python-version: ${{inputs.python-version}}

- name: Install dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip
python3 -m pip install pytest
python3 -m pip install pytest-cov
python3 -m pip install -e .[tests,gym,memory_storage]

- name: Tests
shell: bash
run: |
pytest --cov=cst_python --cov-report json

- if: ${{inputs.os == 'ubuntu-latest' && inputs.python-version == '3.12'}}
name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage_report
path: coverage.json

199 changes: 199 additions & 0 deletions dev/LogicalTime.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"import abc\n",
"import functools\n",
"\n",
"from typing import Self"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"import abc\n",
"import functools\n",
"\n",
"from typing import Self\n",
"\n",
"class LogicalTime(abc.ABC):\n",
"\n",
" @abc.abstractmethod\n",
" def increment(self) -> \"LogicalTime\":\n",
" ...\n",
"\n",
"\n",
" @abc.abstractmethod\n",
" def __str__(self) -> str:\n",
" ...\n",
" \n",
" @classmethod\n",
" @abc.abstractmethod\n",
" def from_str(cls, string:str) -> \"LogicalTime\":\n",
" ...\n",
"\n",
" @classmethod\n",
" @abc.abstractmethod\n",
" def syncronize(cls, time0:Self, time1:Self) -> \"LogicalTime\":\n",
" ...\n",
"\n",
" @abc.abstractmethod\n",
" def __eq__(self, other) -> bool:\n",
" ...\n",
" \n",
" @abc.abstractmethod\n",
" def __lt__(self, other) -> bool:\n",
" ...\n",
"\n",
" @abc.abstractmethod\n",
" def __le__(self, other) -> bool:\n",
" ...\n",
"\n",
" @abc.abstractmethod\n",
" def __gt__(self, other) -> bool:\n",
" ...\n",
"\n",
" @abc.abstractmethod\n",
" def __ge__(self, other) -> bool:\n",
" ...\n",
"\n",
"\n",
"@functools.total_ordering\n",
"class LamportTime(LogicalTime):\n",
" __le__ = object.__lt__\n",
" __gt__ = object.__gt__\n",
" __ge__ = object.__ge__\n",
"\n",
"\n",
" def __init__(self, initial_time:int=0):\n",
" super().__init__()\n",
" self._time = initial_time\n",
"\n",
" def increment(self) -> \"LamportTime\":\n",
" return LamportTime(initial_time=self._time+1)\n",
"\n",
" def __eq__(self, other) -> bool:\n",
" return self._time == other._time\n",
"\n",
" def __lt__(self, other) -> bool:\n",
" return self._time < other._time \n",
"\n",
" def __str__(self) -> str:\n",
" return str(self._time)\n",
"\n",
" @classmethod\n",
" def from_str(cls, string:str) -> \"LamportTime\":\n",
" return LamportTime(int(string))\n",
"\n",
" @classmethod\n",
" def syncronize(cls, time0:Self, time1:Self) -> \"LamportTime\":\n",
" new_time = 0\n",
" if time0 < time1:\n",
" new_time = time1._time\n",
" else:\n",
" new_time = time0._time\n",
"\n",
" new_time += 1\n",
"\n",
" return LamportTime(new_time)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"time0 = LamportTime()"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n"
]
}
],
"source": [
"print(time0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n"
]
}
],
"source": [
"time1 = time0.increment()\n",
"print(time1)"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n"
]
}
],
"source": [
"time3 = LamportTime.syncronize(time0, time1)\n",
"print(time3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading