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

🐛 unarchiving_utils are now based on 7zip cli #6959

Open
wants to merge 57 commits into
base: master
Choose a base branch
from

Conversation

GitHK
Copy link
Contributor

@GitHK GitHK commented Dec 12, 2024

What do these changes do?

When a new style dynamic service has to fetch an input port containing a zip archive, it will try to unzip it.
If it's not able to open it (see issue here), the service would fail to start.

Important changes:

Related issue/s

How to test

Dev-ops checklist

@GitHK GitHK self-assigned this Dec 12, 2024
@GitHK GitHK added the a:dynamic-sidecar dynamic-sidecar service label Dec 12, 2024
@GitHK GitHK added bug buggy, it does not work as expected t:maintenance Some planned maintenance work and removed bug buggy, it does not work as expected labels Dec 12, 2024
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 79.81651% with 44 lines in your changes missing coverage. Please review.

Project coverage is 86.84%. Comparing base (68f0b24) to head (7041eee).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6959      +/-   ##
==========================================
- Coverage   87.02%   86.84%   -0.18%     
==========================================
  Files        1621     1286     -335     
  Lines       63993    54997    -8996     
  Branches     2035     1161     -874     
==========================================
- Hits        55687    47764    -7923     
+ Misses       7972     7021     -951     
+ Partials      334      212     -122     
Flag Coverage Δ
integrationtests 64.58% <16.00%> (-10.42%) ⬇️
unittests 84.95% <79.81%> (-1.02%) ⬇️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library 93.49% <ø> (ø)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library 73.53% <88.08%> (+0.30%) ⬆️
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 85.38% <ø> (ø)
agent 96.82% <ø> (ø)
api_server 90.13% <ø> (ø)
autoscaling 96.09% <ø> (ø)
catalog 90.57% <ø> (ø)
clusters_keeper 99.48% <ø> (ø)
dask_sidecar 91.26% <ø> (ø)
datcore_adapter 93.18% <ø> (ø)
director 76.40% <ø> (ø)
director_v2 90.68% <ø> (-0.74%) ⬇️
dynamic_scheduler 97.19% <ø> (ø)
dynamic_sidecar 89.76% <16.00%> (+0.01%) ⬆️
efs_guardian 90.12% <ø> (ø)
invitations 93.44% <ø> (ø)
osparc_gateway_server ∅ <ø> (∅)
payments 92.66% <ø> (ø)
resource_usage_tracker 89.62% <ø> (+0.05%) ⬆️
storage 89.54% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 84.41% <ø> (-0.03%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 68f0b24...7041eee. Read the comment docs.

@GitHK GitHK marked this pull request as ready for review December 13, 2024 05:47
Copy link
Member

@odeimaiz odeimaiz left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

What is the idea behing this change?

Also I was wondering:

  • the dask-sidecar checks the input file mime type. if it is set to zip, then it does not uncompress

@GitHK GitHK requested a review from sanderegg December 13, 2024 10:15
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

Please read my additional comments. I don't undersatnd how you wanna present this error to the user.

@GitHK GitHK changed the title 🐛 Replace unarchiving function 🐛 unarchiving_utils are now based on 7zip cli Dec 19, 2024
@GitHK GitHK added the a:webserver issue related to the webserver service label Dec 20, 2024
@GitHK
Copy link
Contributor Author

GitHK commented Dec 20, 2024

@giancarloromeo @matusdrobuliak66 @sanderegg
I've rewritten the entire logic here. please review it as if it were a new.
Thanks a lot

Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

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

thanks, but please let's look at some of the comments. we can have a quick chat.

@@ -0,0 +1,4 @@
class ArchiveError(Exception):
Copy link
Member

Choose a reason for hiding this comment

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

not using OsparcMixinError??

Comment on lines +41 to +65
class ArchiveInfoParser:
def __init__(self) -> None:
self.total_bytes: NonNegativeInt | None = None
self.file_count: NonNegativeInt | None = None

async def parse_chunk(self, chunk: str) -> None:
# search for ` NUMBER bytes ` -> set byte size
if self.total_bytes is None and (match := re.search(_TOTAL_BYTES_RE, chunk)):
self.total_bytes = int(match.group(1))

# search for ` NUMBER files` -> set file count
if self.file_count is None and (match := re.search(_FILE_COUNT_RE, chunk)):
self.file_count = int(match.group(1))

def get_parsed_values(self) -> tuple[NonNegativeInt, NonNegativeInt]:
if self.total_bytes is None:
msg = f"Unexpected value for {self.total_bytes=}. Should not be None"
raise ArchiveError(msg)

if self.file_count is None:
msg = f"Unexpected value for {self.file_count=}. Should not be None"
raise ArchiveError(msg)

return (self.total_bytes, self.file_count)

Copy link
Member

Choose a reason for hiding this comment

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

you use pydantic types in a non pydantic class.
Why not use at a dataclass? or pydantic at this point.

@@ -187,7 +187,7 @@ h11==0.14.0
# uvicorn
httpcore==1.0.7
# via httpx
httpx==0.28.0
httpx==0.28.1
Copy link
Member

Choose a reason for hiding this comment

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

why is httpx updated here?

@@ -93,7 +93,7 @@ httpcore==1.0.7
# via
# -c requirements/_base.txt
# httpx
httpx==0.28.0
httpx==0.28.1
Copy link
Member

Choose a reason for hiding this comment

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

why is httpx updated here?

@@ -112,7 +112,7 @@ httpcore==1.0.7
# via
# -c requirements/_base.txt
# httpx
httpx==0.28.0
httpx==0.28.1
Copy link
Member

Choose a reason for hiding this comment

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

?

@@ -328,11 +328,11 @@ opentelemetry-instrumentation-fastapi==0.49b2
# via -r requirements/../../../packages/service-library/requirements/_fastapi.in
opentelemetry-instrumentation-httpx==0.49b2
# via -r requirements/../../../packages/service-library/requirements/_fastapi.in
opentelemetry-instrumentation-logging==0.48b0
opentelemetry-instrumentation-logging==0.49b2
Copy link
Member

Choose a reason for hiding this comment

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

there are a few updates I don't quite get why they come here. are you sure about these?

start_time = time.perf_counter()

settings: ApplicationSettings = get_settings()
PORTS: Nodeports = await node_ports_v2.ports(
user_id=settings.DY_SIDECAR_USER_ID,
project_id=ProjectIDStr(settings.DY_SIDECAR_PROJECT_ID),
node_uuid=NodeIDStr(settings.DY_SIDECAR_NODE_ID),
node_uuid=TypeAdapter(NodeIDStr).validate_python(settings.DY_SIDECAR_NODE_ID),
Copy link
Member

Choose a reason for hiding this comment

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

NodeIDStr is just a string. not sure you need to use the typeadapter here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:dynamic-sidecar dynamic-sidecar service a:webserver issue related to the webserver service t:maintenance Some planned maintenance work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deflate64 zip-files not supported by dynamic-sidecar powered services
6 participants