feat: support python 3.7

This commit is contained in:
youben11
2022-08-15 10:12:23 +01:00
committed by Ayoub Benaissa
parent 3aef4cd932
commit ecb70e2893
13 changed files with 276 additions and 1090 deletions

View File

@@ -30,6 +30,7 @@ jobs:
outputs:
linux-matrix: ${{ steps.set-matrix.outputs.linux-matrix }}
macos-matrix: ${{ steps.set-matrix.outputs.macos-matrix }}
needs-37-linux-runner: ${{ steps.set-matrix.outputs.needs-37-linux-runner }}
needs-38-linux-runner: ${{ steps.set-matrix.outputs.needs-38-linux-runner }}
needs-39-linux-runner: ${{ steps.set-matrix.outputs.needs-39-linux-runner }}
steps:
@@ -69,17 +70,23 @@ jobs:
echo "::set-output name=linux-matrix::${LINUX_MATRIX}"
echo "::set-output name=macos-matrix::${MACOS_MATRIX}"
NEEDS_LINUX_37_RUNNER=$(echo "${LINUX_MATRIX}" | \
jq -rc '. | map(select(.os_kind=="linux" and .python_version=="3.7")) | length > 0')
NEEDS_LINUX_38_RUNNER=$(echo "${LINUX_MATRIX}" | \
jq -rc '. | map(select(.os_kind=="linux" and .python_version=="3.8")) | length > 0')
NEEDS_LINUX_39_RUNNER=$(echo "${LINUX_MATRIX}" | \
jq -rc '. | map(select(.os_kind=="linux" and .python_version=="3.9")) | length > 0')
echo "Needs Linux 3.7 runner:"
echo "${NEEDS_LINUX_37_RUNNER}"
echo "Needs Linux 3.8 runner:"
echo "${NEEDS_LINUX_38_RUNNER}"
echo "Needs Linux 3.9 runner:"
echo "${NEEDS_LINUX_39_RUNNER}"
echo "::set-output name=needs-37-linux-runner::${NEEDS_LINUX_37_RUNNER}"
echo "::set-output name=needs-38-linux-runner::${NEEDS_LINUX_38_RUNNER}"
echo "::set-output name=needs-39-linux-runner::${NEEDS_LINUX_39_RUNNER}"
@@ -88,6 +95,8 @@ jobs:
name: Start EC2 runner
runs-on: ubuntu-20.04
outputs:
label-37: ${{ steps.start-ec2-runner-37.outputs.label }}
ec2-instance-id-37: ${{ steps.start-ec2-runner-37.outputs.ec2-instance-id || '' }}
label-38: ${{ steps.start-ec2-runner-38.outputs.label }}
ec2-instance-id-38: ${{ steps.start-ec2-runner-38.outputs.ec2-instance-id || '' }}
label-39: ${{ steps.start-ec2-runner-39.outputs.label }}
@@ -104,6 +113,18 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Start EC2 runner python 37
id: start-ec2-runner-37
if: ${{ !cancelled() && fromJSON(needs.matrix-preparation.outputs.needs-37-linux-runner) }}
uses: machulav/ec2-github-runner@c34ba2df3363ebde9d19fdbc341e03d02267284d
with:
mode: start
github-token: ${{ secrets.EC2_RUNNER_BOT_TOKEN }}
ec2-image-id: ${{ secrets.AWS_EC2_AMI }}
ec2-instance-type: ${{ secrets.AWS_EC2_INSTANCE_TYPE }}
subnet-id: ${{ secrets.AWS_EC2_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_EC2_SECURITY_GROUP_ID }}
- name: Start EC2 runner python 38
id: start-ec2-runner-38
if: ${{ !cancelled() && fromJSON(needs.matrix-preparation.outputs.needs-38-linux-runner) }}
@@ -133,6 +154,8 @@ jobs:
env:
MATRIX: ${{ needs.matrix-preparation.outputs.linux-matrix }}
run: |
MATRIX=$(echo "${MATRIX}" | jq -rc \
'(. | map(select(.os_kind=="linux" and .python_version=="3.7") |= . + {"runs_on": "${{ steps.start-ec2-runner-37.outputs.label }}"}) )')
MATRIX=$(echo "${MATRIX}" | jq -rc \
'(. | map(select(.os_kind=="linux" and .python_version=="3.8") |= . + {"runs_on": "${{ steps.start-ec2-runner-38.outputs.label }}"}) )')
MATRIX=$(echo "${MATRIX}" | jq -rc \
@@ -349,6 +372,15 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Stop EC2 runner python 37
uses: machulav/ec2-github-runner@c34ba2df3363ebde9d19fdbc341e03d02267284d
if: ${{ always() && needs.start-runner-linux.outputs.ec2-instance-id-37 }}
with:
github-token: ${{ secrets.EC2_RUNNER_BOT_TOKEN }}
label: ${{ needs.start-runner-linux.outputs.label-37 }}
ec2-instance-id: ${{ needs.start-runner-linux.outputs.ec2-instance-id-37 }}
mode: stop
- name: Stop EC2 runner python 38
uses: machulav/ec2-github-runner@c34ba2df3363ebde9d19fdbc341e03d02267284d
if: ${{ always() && needs.start-runner-linux.outputs.ec2-instance-id-38 }}

View File

@@ -47,7 +47,10 @@ def univariate(
else np.int64
)
sample = dtype(1) if x.output.shape == () else np.ones(x.output.shape, dtype=dtype)
if x.output.shape == ():
sample = dtype(1) # type: ignore
else:
sample = np.ones(x.output.shape, dtype=dtype)
evaluation = function(sample)
output_value = Value.of(evaluation, is_encrypted=x.output.is_encrypted)

View File

@@ -194,7 +194,8 @@ class GraphConverter:
if len(offending_nodes) == 0:
for node in graph.graph.nodes:
if (reason := GraphConverter._check_node_convertibility(graph, node)) is not None:
reason = GraphConverter._check_node_convertibility(graph, node)
if reason is not None:
offending_nodes[node] = [reason]
if len(offending_nodes) != 0:

View File

@@ -2,7 +2,6 @@
Declaration of various functions and constants related to MLIR conversion.
"""
import math
from collections import defaultdict, deque
from copy import deepcopy
from itertools import product
@@ -165,7 +164,7 @@ def construct_deduplicated_tables(
tables_to_cell_idx[hashable_array].append(idx)
all_idx_set.add(idx)
assert_that(len(all_idx_set) == math.prod(node_complete_table.shape[:-1]))
assert_that(len(all_idx_set) == np.prod(node_complete_table.shape[:-1]))
return tuple(
(hashable_array.array, indices) for hashable_array, indices in tables_to_cell_idx.items()

View File

@@ -2,7 +2,6 @@
Declaration of `Value` class.
"""
from math import prod
from typing import Any, Tuple
import numpy as np
@@ -159,4 +158,4 @@ class Value:
number of elements in the value
"""
return int(prod(self.shape))
return int(np.prod(self.shape))

View File

@@ -76,7 +76,6 @@ Some of these operations are not supported between two encrypted values. A detai
* [np.cosh](https://numpy.org/doc/stable/reference/generated/numpy.cosh.html)
* [np.deg2rad](https://numpy.org/doc/stable/reference/generated/numpy.deg2rad.html)
* [np.degrees](https://numpy.org/doc/stable/reference/generated/numpy.degrees.html)
* [np.divide](https://numpy.org/doc/stable/reference/generated/numpy.divide.html)
* [np.dot](https://numpy.org/doc/stable/reference/generated/numpy.dot.html)
* [np.equal](https://numpy.org/doc/stable/reference/generated/numpy.equal.html)
* [np.exp](https://numpy.org/doc/stable/reference/generated/numpy.exp.html)
@@ -143,6 +142,7 @@ Some of these operations are not supported between two encrypted values. A detai
* [np.tan](https://numpy.org/doc/stable/reference/generated/numpy.tan.html)
* [np.tanh](https://numpy.org/doc/stable/reference/generated/numpy.tanh.html)
* [np.transpose](https://numpy.org/doc/stable/reference/generated/numpy.transpose.html)
* [np.true\_divide](https://numpy.org/doc/stable/reference/generated/numpy.true\_divide.html)
* [np.trunc](https://numpy.org/doc/stable/reference/generated/numpy.trunc.html)
* [np.where](https://numpy.org/doc/stable/reference/generated/numpy.where.html)
* [np.zeros\_like](https://numpy.org/doc/stable/reference/generated/numpy.zeros\_like.html)

View File

@@ -6,8 +6,8 @@
fonttools 4.36.0 MIT License
kiwisolver 1.4.4 BSD License
matplotlib 3.5.3 Python Software Foundation License
networkx 2.8.5 BSD License
numpy 1.23.2 BSD License
networkx 2.6.3 BSD License
numpy 1.21.6 BSD License
packaging 21.3 Apache Software License; BSD License
pyparsing 3.0.9 MIT License
python-dateutil 2.8.2 Apache Software License; BSD License
@@ -15,4 +15,4 @@
six 1.16.0 MIT License
tomli 2.0.1 MIT License
torch 1.12.1 BSD License
typing-extensions 4.3.0 Python Software Foundation License
typing-extensions 3.10.0.2 Python Software Foundation License

1275
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,10 +37,10 @@ readme = "README.md"
"Discourse" = "https://community.zama.ai/c/concrete-numpy/7"
[tool.poetry.dependencies]
python = ">=3.8,<3.10"
python = ">=3.7,<3.10"
networkx = "^2.6.3"
matplotlib = "^3.5.1"
numpy = "^1.22.0"
numpy = "^1.21.0"
Pillow = "^9.0.0"
concrete-compiler = "^0.15.0"
torch = "^1.10.2"

View File

@@ -16,18 +16,18 @@ MACOS = "macos"
OSES = {LINUX, MACOS}
PR_OSES = {LINUX: "ubuntu-20.04"}
PR_PYTHON_VERSIONS = ["3.8"]
PR_PYTHON_VERSIONS = ["3.7"]
PR_CONF = {"os": PR_OSES, "python": PR_PYTHON_VERSIONS}
PUSH_TO_MAIN_OSES = {LINUX: "ubuntu-20.04"}
PUSH_TO_MAIN_PYTHON_VERSIONS = ["3.8"]
PUSH_TO_MAIN_PYTHON_VERSIONS = ["3.7"]
PUSH_TO_MAIN_CONF = {"os": PUSH_TO_MAIN_OSES, "python": PUSH_TO_MAIN_PYTHON_VERSIONS}
WEEKLY_OSES = {
LINUX: "ubuntu-20.04",
MACOS: "macos-11",
}
WEEKLY_PYTHON_VERSIONS = ["3.8", "3.9"]
WEEKLY_PYTHON_VERSIONS = ["3.7", "3.8", "3.9"]
WEEKLY_CONF = {"os": WEEKLY_OSES, "python": WEEKLY_PYTHON_VERSIONS}
# The OSes here are to indicate the OSes used for runners during release
@@ -38,7 +38,7 @@ RELEASE_OSES = {
# MACOS: "macos-10.15",
}
# The python versions will be used to build packages during release
RELEASE_PYTHON_VERSIONS = ["3.8", "3.9"]
RELEASE_PYTHON_VERSIONS = ["3.7", "3.8", "3.9"]
RELEASE_CONF = {"os": RELEASE_OSES, "python": RELEASE_PYTHON_VERSIONS}
CONFIGURATIONS = {

View File

@@ -89,9 +89,8 @@ def main(args):
)
version_tags.append(potential_version_tag.string)
assert (
num_version_tags := len(version_tags) == 1
), f"Can only have 1 version tag, got {num_version_tags}"
num_version_tags = len(version_tags)
assert num_version_tags == 1, f"Can only have 1 version tag, got {num_version_tags}"
version_tag = version_tags[0]

View File

@@ -131,12 +131,15 @@ def main(args):
from_commit = None
if args.from_ref is None:
tags_by_name = {strip_leading_v(tag.name): tag for tag in repo.tags}
all_release_version_infos = {
version_info: tags_by_name[tag_name]
version_infos = {
VersionInfo.parse(tag_name): tag_name
for tag_name in tags_by_name
if VersionInfo.isvalid(tag_name)
and (version_info := VersionInfo.parse(tag_name))
and version_info.prerelease is None
}
all_release_version_infos = {
version_info: tags_by_name[tag_name]
for version_info, tag_name in version_infos.items()
if version_info.prerelease is None
}
log_msg(f"All release versions {all_release_version_infos}")

View File

@@ -34,12 +34,13 @@ def islatest(args):
)
# Keep versions that are not release candidate
all_non_prerelease_version_infos = [
version_info
version_infos = [
VersionInfo.parse(version_str)
for version_str in all_versions_str
if VersionInfo.isvalid(version_str)
and (version_info := VersionInfo.parse(version_str))
and version_info.prerelease is None
]
all_non_prerelease_version_infos = [
version_info for version_info in version_infos if version_info.prerelease is None
]
all_non_prerelease_version_infos.append(new_version_info)