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

[sub]fix(backend/image_transfert/encoder): update pydantic method #763

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

thbcmlowk
Copy link
Contributor

Description

Closes FL-1242

How has this been tested?

Checklist

  • changelog was updated with notable changes
  • documentation was updated

@linear
Copy link

linear bot commented Oct 12, 2023

FL-1242 [BUG] `dumps_kwargs` keyword arguments are no longer supported

Context

FLPC v3 has been deployed

Test Compute Plan has been launched (Camelyon)

The following error is raised in the worker pod:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 451, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 734, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/celery/app/autoretry.py", line 34, in run
    return task._orig_run(*args, **kwargs)
  File "/usr/src/app/substrapp/tasks/tasks_save_image.py", line 83, in save_image_task
    make_payload(
  File "/usr/src/app/image_transfer/encoder.py", line 178, in make_payload
    create_zip_from_docker_images(
  File "/usr/src/app/image_transfer/encoder.py", line 136, in create_zip_from_docker_images
    zip_file.writestr("payload_descriptor.json", payload_descriptor.json(indent=4))
  File "/usr/local/lib/python3.9/site-packages/typing_extensions.py", line 2360, in wrapper
    return arg(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pydantic/main.py", line 960, in json
    raise TypeError('`dumps_kwargs` keyword arguments are no longer supported.')
TypeError: `dumps_kwargs` keyword arguments are no longer supported.

One side effect is:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 451, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 734, in __protected_call__
    return self.run(*args, **kwargs)
  File "/usr/src/app/substrapp/tasks/tasks_asset_failure_report.py", line 53, in store_asset_failure_report
    failure_report = store_failure(exception, asset_key, asset_type, error_type)
  File "/usr/src/app/substrapp/utils/errors.py", line 27, in store_failure
    file = files.File(exception.logs)
AttributeError: 'TypeError' object has no attribute 'logs'

Environment

  substra_version = {
    "orchestrator" = {
      app   = "0.37.0-beta3"
      chart = "8.0.0"
    }
    "substra-backend" = {
      app   = "0.43.0-beta2"
      chart = "24.0.0-beta1"
    }
    "substra-frontend" = {
      app   = "0.46.0-beta3"
      chart = "1.0.24"
    }
    "substra-tools" = {
      app = "0.21.0"
    }
  }

Symptoms

Compute Plan launched is stuck in Doing while the builder is no longer busy

image.png

Specification

Fix the TypeError

Acceptance criteria

TypeError is not raised anymore by the worker

@thbcmlowk thbcmlowk changed the title fix(backend/image_transfert/encoder): update pydantic method [sub]fix(backend/image_transfert/encoder): update pydantic method Oct 12, 2023
@thbcmlowk thbcmlowk marked this pull request as ready for review October 12, 2023 06:57
@thbcmlowk thbcmlowk requested a review from a team as a code owner October 12, 2023 06:57
@@ -133,7 +133,7 @@ def create_zip_from_docker_images(
dest = payload_descriptor.manifests_paths[manifest.docker_image_name]
zip_file.writestr(dest, manifest.content)

zip_file.writestr("payload_descriptor.json", payload_descriptor.json(indent=4))
zip_file.writestr("payload_descriptor.json", payload_descriptor.model_dump_json(indent=4))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to change also PayloadDescriptor.parse_raw into PayloadDescriptor.model_validate_json in decoder.py

Copy link
Contributor Author

@thbcmlowk thbcmlowk Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! You mean here and like this, right?

-    return PayloadDescriptor.parse_raw(zip_file.read("payload_descriptor.json").decode())
+    return PayloadDescriptor.model_validate_json(zip_file.read("payload_descriptor.json").decode())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep ! (I did it for the PR refactor image transfer that's why ^^")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also made the pydantic upgrade, but still 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

@ThibaultFy ThibaultFy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect :)

@thbcmlowk thbcmlowk merged commit df97b97 into poc-decoupled-builder Oct 12, 2023
4 checks passed
@thbcmlowk thbcmlowk deleted the fix/pydantic-updates branch October 12, 2023 08:56
SdgJlbl pushed a commit that referenced this pull request Oct 20, 2023
* fix(backend/image_transfert/encoder): update pydantic method

Signed-off-by: Thibault Camalon <[email protected]>

* fix(backend/image_transfer/decoder): parse_raw -> model_validate_json

Signed-off-by: Thibault Camalon <[email protected]>

---------

Signed-off-by: Thibault Camalon <[email protected]>
thbcmlowk added a commit that referenced this pull request Oct 24, 2023
* fix(backend/image_transfert/encoder): update pydantic method

Signed-off-by: Thibault Camalon <[email protected]>

* fix(backend/image_transfer/decoder): parse_raw -> model_validate_json

Signed-off-by: Thibault Camalon <[email protected]>

---------

Signed-off-by: Thibault Camalon <[email protected]>
SdgJlbl added a commit that referenced this pull request Oct 25, 2023
* feat: decouple image builder from worker

Signed-off-by: SdgJlbl <[email protected]>

* fix: update skaffold config

Signed-off-by: Guilhem Barthes <[email protected]>

* feat: add `ServiceAccount` and modify role

Signed-off-by: Guilhem Barthes <[email protected]>

* fix: improve `wait_for_image_built`

Signed-off-by: Guilhem Barthes <[email protected]>

* feat: build image in new pod

Signed-off-by: Guilhem Barthes <[email protected]>

* chore: rename `deployment-builder.yaml` to `stateful-builder.yaml`

Signed-off-by: Guilhem Barthes <[email protected]>

* chore: rename `stateful-builder.yaml` to `statefulset-builder.yaml`

Signed-off-by: Guilhem Barthes <[email protected]>

* chore: centralize params

Signed-off-by: Guilhem Barthes <[email protected]>

* feat: create `BuildTask`

Signed-off-by: Guilhem Barthes <[email protected]>

* feat: move some values to `builder` module

Signed-off-by: Guilhem Barthes <[email protected]>

* feat: move more code to `builder`

Signed-off-by: Guilhem Barthes <[email protected]>

* fix: remove TaskProfiling as Celery task + save Entrypoint in DB

Signed-off-by: SdgJlbl <[email protected]>

* fix: extract entrypoint from registry

Signed-off-by: SdgJlbl <[email protected]>

* fix: make doc for helm chart

Signed-off-by: SdgJlbl <[email protected]>

* feat: build function at registration (#707)

<!-- Please reference issue if any. -->

<!-- Please include a summary of your changes. -->

<!-- Please describe the tests that you ran to verify your changes.  -->

- [ ] [changelog](../CHANGELOG.md) was updated with notable changes
- [ ] documentation was updated

---------

Signed-off-by: SdgJlbl <[email protected]>
Signed-off-by: Guilhem Barthes <[email protected]>
Co-authored-by: SdgJlbl <[email protected]>

* feat: share images between backends (#708)



Signed-off-by: SdgJlbl <[email protected]>

* chore: update helm worklfow

Signed-off-by: ThibaultFy <[email protected]>

* chore: add .DS_Store to gitignore

Signed-off-by: ThibaultFy <[email protected]>

* chore: rm DS_Store

Signed-off-by: ThibaultFy <[email protected]>

* chore: rm .DS_Store

Signed-off-by: ThibaultFy <[email protected]>

* [sub]fix: add missing migration poc (#728)

## Description

Add a migration missing in the poc. 
This migration alters two things:

-  modify `ComputeTaskFailureReport.logs` 
-  modify `FunctionImage.file`

This migration has been generated automatically with `make migrations`

## How has this been tested?

<!-- Please describe the tests that you ran to verify your changes.  -->

## Checklist

- [ ] [changelog](../CHANGELOG.md) was updated with notable changes
- [ ] documentation was updated

Signed-off-by: Guilhem Barthes <[email protected]>

* [sub]feat: add function events (#714)

- Substra/orchestrator#263

Add function events, used now we decoupled the building of the function
with the execution of the compute task. For that it add a status field
on the Function. It also includes another PR (merged here), to have
functions build logs working again.

In a future PR, we will change the compute task execution to avoid
having to wait_for_function_built in compute_task()

Fixes FL-1160

As this is going to be merged on a branch that is going to be merged to
a POC branch, we use MNIST as a baseline of a working model. We will
deal with failing tests on the POC before merging on main.

- [x] [changelog](../CHANGELOG.md) was updated with notable changes
- [ ] documentation was updated

---------

Signed-off-by: SdgJlbl <[email protected]>
Signed-off-by: Guilhem Barthes <[email protected]>
Signed-off-by: Guilhem Barthés <[email protected]>
Co-authored-by: SdgJlbl <[email protected]>

* [sub]fix(app/orchestrator/resources): FunctionStatus.FUNCTION_STATUS_CREATED -> FunctionStatus.FUNCTION_STATUS_WAITING (#742)

# Issue

Backend FunctionStatus are not aligned with [orchestrator
definitions](https://github.com/Substra/orchestrator/blob/poc-decoupled-builder/lib/asset/function.proto#L29-L36).
In particular, `FunctionStatus.FUNCTION_STATUS_CREATED` leading to the
following error:

```txt
ValueError: 'FUNCTION_STATUS_WAITING' is not a valid FunctionStatus
```

## Description

FunctionStatus.FUNCTION_STATUS_CREATED ->
FunctionStatus.FUNCTION_STATUS_WAITING

## How has this been tested?

Running Camelyon benchmark on
[poc-builder-flpc](https://substra.org-1.poc-builder-flpc.cg.owkin.tech/compute_plans/a420306f-5719-412b-ab9c-688b7bed9c70/tasks?page=1&ordering=-rank)
environment.

## Checklist

- [ ] [changelog](../CHANGELOG.md) was updated with notable changes
- [ ] documentation was updated

---------

Signed-off-by: Thibault Camalon <[email protected]>

* fix: builder using builder SA (#754)

* fix: builder using builder SA

Signed-off-by: Guilhem Barthés <[email protected]>

* docs: changelog

Signed-off-by: Guilhem Barthés <[email protected]>

---------

Signed-off-by: Guilhem Barthés <[email protected]>

* fix: rebase changelog

Signed-off-by: Guilhem Barthés <[email protected]>

* fix: adapt to pydantic 2.x.x (#758)

Signed-off-by: Guilhem Barthés <[email protected]>

* [sub]fix(backend/image_transfert/encoder): update pydantic method (#763)

* fix(backend/image_transfert/encoder): update pydantic method

Signed-off-by: Thibault Camalon <[email protected]>

* fix(backend/image_transfer/decoder): parse_raw -> model_validate_json

Signed-off-by: Thibault Camalon <[email protected]>

---------

Signed-off-by: Thibault Camalon <[email protected]>

* [sub]chore: upgrade chart (#765)

* chore(charts): bump chart version

Signed-off-by: Thibault Camalon <[email protected]>

* chore(charts/substra-backend/CHANGELOG): bring back unreleased section

Signed-off-by: Thibault Camalon <[email protected]>

---------

Signed-off-by: Thibault Camalon <[email protected]>

* fix: post-rebase

Signed-off-by: SdgJlbl <[email protected]>

* chore: rationalize migrations

Signed-off-by: SdgJlbl <[email protected]>

* [sub]chore(builder): waitPostgresqlInitContainer (#764)

* fix: builder using builder SA (#754)

* fix: builder using builder SA

Signed-off-by: Guilhem Barthés <[email protected]>

* docs: changelog

Signed-off-by: Guilhem Barthés <[email protected]>

---------

Signed-off-by: Guilhem Barthés <[email protected]>

* chore(charts/substra-backend/templates/statefulset-builder): add init-container waitPostgresqlInitContainer

Signed-off-by: Thibault Camalon <[email protected]>

---------

Signed-off-by: Guilhem Barthés <[email protected]>
Signed-off-by: Thibault Camalon <[email protected]>
Co-authored-by: Guilhem Barthés <[email protected]>

---------

Signed-off-by: SdgJlbl <[email protected]>
Signed-off-by: Guilhem Barthes <[email protected]>
Signed-off-by: ThibaultFy <[email protected]>
Signed-off-by: Guilhem Barthés <[email protected]>
Signed-off-by: Thibault Camalon <[email protected]>
Co-authored-by: SdgJlbl <[email protected]>
Co-authored-by: ThibaultFy <[email protected]>
Co-authored-by: Thibault Camalon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants