Skip to content

Commit

Permalink
chore: remove chaincode on codebase (#795)
Browse files Browse the repository at this point in the history
Signed-off-by: ThibaultFy <[email protected]>
  • Loading branch information
ThibaultFy authored Jan 4, 2024
1 parent fdfd1f7 commit ec51fa8
Show file tree
Hide file tree
Showing 31 changed files with 29 additions and 69 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

- Remove mention of `chaincode` after `distributed mode` deprecation ([#795](https://github.com/Substra/substra-backend/pull/795))
- BREAKING: remove `distributed` Skaffold profile [#768](https://github.com/Substra/substra-backend/pull/768)

## [0.42.2](https://github.com/Substra/substra-backend/releases/tag/0.42.2) 2023-10-18
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ Provided you have correctly setup your [network configuration](https://doc.subst

## Compatibility

Make sure you deploy this backend with a compatible ecosystem (chaincode, hlf-k8s, etc).
Always refer to the [compatibility table](https://github.com/SubstraFoundation/substra#compatibility-table).
Make sure you deploy this backend with a compatible ecosystem.
Always refer to the [compatibility table](https://docs.substra.org/en/stable/additional/release.html).

The recommended way to run a specific version (0.1.6) of substra-backend is to execute:
The recommended way to run a specific version (X.Y.Z) of substra-backend is to execute:

```bash
SUBSTRA_BACKEND_VERSION=0.1.6
SUBSTRA_BACKEND_VERSION=X.Y.Z
git checkout $SUBSTRA_BACKEND_VERSION
skaffold deploy --images substrafoundation/substra-backend:$SUBSTRA_BACKEND_VERSION
```
Expand Down
2 changes: 1 addition & 1 deletion backend/api/tests/views/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
MEDIA_ROOT = tempfile.mkdtemp()


@override_settings(CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}})
@override_settings(CHANNELS={"mychannel": {"model_export_enabled": True}})
class PermissionMixinDownloadFileTests(APITestCase):
client_class = AuthenticatedClient

Expand Down
2 changes: 1 addition & 1 deletion backend/api/tests/views/test_views_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
)
class AuthenticationTests(APITestCase):
def setUp(self):
Expand Down
4 changes: 1 addition & 3 deletions backend/api/tests/views/test_views_compute_plan_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ def create_compute_graph():
return compute_plan, train_task, predict_task, test_task, composite_task, aggregate_task


@override_settings(
MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}}
)
@override_settings(MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"model_export_enabled": True})
class ComputePlanGraphViewTests(APITestCase):
client_class = AuthenticatedClient

Expand Down
4 changes: 2 additions & 2 deletions backend/api/tests/views/test_views_computeplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class AuthenticatedAPITestCase(APITestCase):
@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={
"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True},
"yourchannel": {"chaincode": {"name": "yourcc"}, "model_export_enabled": True},
"mychannel": {"model_export_enabled": True},
"yourchannel": {"model_export_enabled": True},
},
)
class ComputePlanViewTests(AuthenticatedAPITestCase):
Expand Down
4 changes: 2 additions & 2 deletions backend/api/tests/views/test_views_computetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def tearDown(self):

@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
)
class TaskBulkCreateViewTests(ComputeTaskViewTests):
def test_task_bulk_create(self):
Expand Down Expand Up @@ -253,7 +253,7 @@ def mock_register_compute_task(orc_request):

@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
)
class GenericTaskViewTests(ComputeTaskViewTests):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion backend/api/tests/views/test_views_datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
MSP_ID="MyTestOrg",
)
class DataManagerViewTests(APITestCase):
Expand Down
2 changes: 1 addition & 1 deletion backend/api/tests/views/test_views_datasample.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def mock_register_datasamples(orc_request):

@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
)
@override_settings(DEFAULT_DOMAIN="https://localhost")
class DataSampleViewTests(APITestCase):
Expand Down
1 change: 0 additions & 1 deletion backend/api/tests/views/test_views_failed_asset_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def test_download_remote_logs_success(
@pytest.fixture
def incoming_organization_user(settings: conf.Settings) -> organization_auth.OrganizationUser:
incoming_organization = "incoming-organization"
settings.CHANNELS.update({incoming_organization: {"chaincode": {"name": "mycc2"}}})
return organization_auth.OrganizationUser(username=incoming_organization)


Expand Down
2 changes: 1 addition & 1 deletion backend/api/tests/views/test_views_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
)
class FunctionViewTests(APITestCase):
client_class = AuthenticatedClient
Expand Down
7 changes: 2 additions & 5 deletions backend/api/tests/views/test_views_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from orchestrator.resources import OrchestratorVersion


@override_settings(CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}})
@override_settings(CHANNELS={"mychannel": {"model_export_enabled": True}})
class InfoViewTests(APITestCase):
url = "/info/"

Expand All @@ -29,9 +29,7 @@ def test_anonymous(self):
def test_authenticated(self):
client = AuthenticatedClient()

with mock.patch.object(
OrchestratorClient, "query_version", return_value=OrchestratorVersion(server="foo", chaincode="bar")
):
with mock.patch.object(OrchestratorClient, "query_version", return_value=OrchestratorVersion(server="foo")):
response = client.get(self.url)

self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand All @@ -44,4 +42,3 @@ def test_authenticated(self):
assert "model_export_enabled" in data["config"]
assert "version" in data
assert data["orchestrator_version"] == "foo"
assert data["chaincode_version"] == "bar"
4 changes: 1 addition & 3 deletions backend/api/tests/views/test_views_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
MEDIA_ROOT = tempfile.mkdtemp()


@override_settings(
MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}}
)
@override_settings(MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"model_export_enabled": True}})
class ComputePlanMetadataViewTests(APITestCase):
client_class = AuthenticatedClient

Expand Down
2 changes: 1 addition & 1 deletion backend/api/tests/views/test_views_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

@override_settings(
MEDIA_ROOT=MEDIA_ROOT,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
MSP_ID=TEST_ORG,
)
class ModelViewTests(APITestCase):
Expand Down
4 changes: 1 addition & 3 deletions backend/api/tests/views/test_views_newsfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
MEDIA_ROOT = tempfile.mkdtemp()


@override_settings(
MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}}
)
@override_settings(MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"model_export_enabled": True}})
class NewsFeedViewTests(APITestCase):
client_class = AuthenticatedClient

Expand Down
4 changes: 1 addition & 3 deletions backend/api/tests/views/test_views_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
MEDIA_ROOT = tempfile.mkdtemp()


@override_settings(
MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}}
)
@override_settings(MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"model_export_enabled": True}})
class CPPerformanceViewTests(APITestCase):
client_class = AuthenticatedClient

Expand Down
2 changes: 1 addition & 1 deletion backend/api/tests/views/test_views_task_profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
TEST_ORG = "MyTestOrg"

ORG_SETTINGS = {
"CHANNELS": {"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
"CHANNELS": {"mychannel": {"model_export_enabled": True}},
"MSP_ID": TEST_ORG,
}

Expand Down
2 changes: 1 addition & 1 deletion backend/backend/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
ORCHESTRATOR_GRPC_KEEPALIVE_MAX_PINGS_WITHOUT_DATA = 0

MSP_ID = "testOrgMSP"
CHANNELS = {"mychannel": {"chaincode": {"name": "mycc"}}}
CHANNELS = {"mychannel": {"model_export_enabled": False}}
3 changes: 0 additions & 3 deletions backend/backend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ def get(self, request, *args, **kwargs):
if hasattr(request.user, "channel"):
res["user_role"] = request.user.channel.role

if orchestrator_versions and orchestrator_versions.chaincode:
res["chaincode_version"] = orchestrator_versions.chaincode

if settings.OIDC["ENABLED"]:
res["auth"]["oidc"] = {
"name": settings.OIDC["OP"]["DISPLAY_NAME"],
Expand Down
3 changes: 0 additions & 3 deletions backend/orchestrator/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def __init__(
target,
channel_name,
mspid,
chaincode,
cacert=None,
client_key=None,
client_cert=None,
Expand Down Expand Up @@ -178,7 +177,6 @@ def __init__(
self._metadata = (
("mspid", mspid),
("channel", channel_name),
("chaincode", chaincode),
)

@property
Expand Down Expand Up @@ -378,7 +376,6 @@ def subscribe_to_events(self, channel_name=None, start_event_id=""):
metadata = (
("mspid", self._mspid),
("channel", channel_name),
("chaincode", settings.CHANNELS[channel_name]["chaincode"]["name"]),
)
else:
metadata = self._metadata
Expand Down
3 changes: 1 addition & 2 deletions backend/orchestrator/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ def __init__(self, actual: AssetKind, expected: AssetKind):

class OrchestratorVersion(pydantic.BaseModel):
server: str
chaincode: str

@classmethod
def from_grpc(cls, orc_version: info_pb2.QueryVersionResponse) -> OrchestratorVersion:
return cls(server=orc_version.orchestrator, chaincode=orc_version.chaincode)
return cls(server=orc_version.orchestrator)
4 changes: 1 addition & 3 deletions backend/organization/tests/views/test_views_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
MEDIA_ROOT = "/tmp/unittests_views/"


@override_settings(
MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}}
)
@override_settings(MEDIA_ROOT=MEDIA_ROOT, CHANNELS={"mychannel": {"model_export_enabled": True}})
class ModelViewTests(APITestCase):
client_class = AuthenticatedClient

Expand Down
6 changes: 1 addition & 5 deletions backend/substrapp/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def get_orchestrator_client(channel_name: str = None) -> OrchestratorClient:
cacert = None
client_key = None
client_cert = None
chaincode = None

if settings.ORCHESTRATOR_TLS_ENABLED:
cacert = settings.ORCHESTRATOR_TLS_SERVER_CACERT_PATH
Expand All @@ -20,14 +19,11 @@ def get_orchestrator_client(channel_name: str = None) -> OrchestratorClient:

mspid = settings.MSP_ID

if channel_name is not None:
chaincode = settings.CHANNELS[channel_name]["chaincode"]["name"]

opts = (
("grpc.keepalive_time_ms", settings.ORCHESTRATOR_GRPC_KEEPALIVE_TIME_MS),
("grpc.keepalive_timeout_ms", settings.ORCHESTRATOR_GRPC_KEEPALIVE_TIMEOUT_MS),
("grpc.keepalive_permit_without_calls", settings.ORCHESTRATOR_GRPC_KEEPALIVE_PERMIT_WITHOUT_CALLS),
("grpc.http2.max_pings_without_data", settings.ORCHESTRATOR_GRPC_KEEPALIVE_MAX_PINGS_WITHOUT_DATA),
)

return OrchestratorClient(host, channel_name, mspid, chaincode, cacert, client_key, client_cert, opts=opts)
return OrchestratorClient(host, channel_name, mspid, cacert, client_key, client_cert, opts=opts)
2 changes: 1 addition & 1 deletion backend/substrapp/tests/compute_tasks/test_asset_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def falsify_content(self, new_content):

@override_settings(
ASSET_BUFFER_DIR=ASSET_BUFFER_DIR,
CHANNELS={"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}},
CHANNELS={"mychannel": {"model_export_enabled": True}},
)
class AssetBufferTests(APITestCase):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion backend/users/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TestUserEndpoints:

@pytest.fixture(autouse=True)
def use_dummy_channels(self, settings):
settings.CHANNELS = {"mychannel": {"chaincode": {"name": "mycc"}, "model_export_enabled": True}}
settings.CHANNELS = {"mychannel": {"model_export_enabled": True}}

@classmethod
def setup_class(cls):
Expand Down
2 changes: 1 addition & 1 deletion charts/substra-backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: substra-backend
home: https://github.com/Substra
version: 24.0.1
version: 24.0.2
appVersion: 0.42.2
kubeVersion: ">= 1.19.0-0"
description: Main package for Substra
Expand Down
1 change: 0 additions & 1 deletion charts/substra-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ See [UPGRADE.md](https://github.com/Substra/substra-backend/blob/main/charts/sub
| `orchestrator.mspID` | current organization name on the Orchestrator | `OwkinPeerMSP` |
| `orchestrator.channels[0].mychannel.restricted` | Make this channel restricted to a single organization. The server will fail if there is more than one instance in this channel | `false` |
| `orchestrator.channels[0].mychannel.model_export_enabled` | Allow logged-in users to download models trained on this organization | `false` |
| `orchestrator.channels[0].mychannel.chaincode.name` | The name of the chaincode instantiated on this channel | `mycc` |

### Kaniko settings

Expand Down
3 changes: 0 additions & 3 deletions charts/substra-backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,10 @@ orchestrator:
channels:
## @param orchestrator.channels[0].mychannel.restricted Make this channel restricted to a single organization. The server will fail if there is more than one instance in this channel
## @param orchestrator.channels[0].mychannel.model_export_enabled Allow logged-in users to download models trained on this organization
## @param orchestrator.channels[0].mychannel.chaincode.name The name of the chaincode instantiated on this channel
##
- mychannel:
restricted: false
model_export_enabled: false
chaincode:
name: mycc

## @section Kaniko settings
##
Expand Down
4 changes: 0 additions & 4 deletions examples/values/backend-org-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ orchestrator:
- mychannel:
restricted: false
model_export_enabled: true
chaincode:
name: mycc
- yourchannel:
restricted: false
model_export_enabled: true
chaincode:
name: yourcc
4 changes: 0 additions & 4 deletions examples/values/backend-org-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ orchestrator:
- mychannel:
restricted: false
model_export_enabled: true
chaincode:
name: mycc
- yourchannel:
restricted: false
model_export_enabled: true
chaincode:
name: yourcc
4 changes: 0 additions & 4 deletions examples/values/backend-org-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ orchestrator:
- mychannel:
restricted: false
model_export_enabled: true
chaincode:
name: mycc
- yourchannel:
restricted: false
model_export_enabled: true
chaincode:
name: yourcc

0 comments on commit ec51fa8

Please sign in to comment.