Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Workers
Base Worker
Commits
f41589b5
Commit
f41589b5
authored
2 years ago
by
NolanB
Browse files
Options
Downloads
Patches
Plain Diff
Commit for help fixing tests
parent
d2a36387
No related branches found
No related tags found
No related merge requests found
Pipeline
#79370
failed
2 years ago
Stage: test
Stage: build
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.isort.cfg
+1
-1
1 addition, 1 deletion
.isort.cfg
tests/test_elements_worker/test_training.py
+33
-43
33 additions, 43 deletions
tests/test_elements_worker/test_training.py
with
34 additions
and
44 deletions
.isort.cfg
+
1
−
1
View file @
f41589b5
...
...
@@ -8,4 +8,4 @@ line_length = 88
default_section
=
FIRSTPARTY
known_first_party
=
arkindex,arkindex_common
known_third_party
=
PIL,apistar,gitlab,gnupg,peewee,playhouse,pytest,recommonmark,requests,
responses,
setuptools,sh,shapely,tenacity,yaml,zstandard
known_third_party
=
PIL,apistar,gitlab,gnupg,peewee,playhouse,pytest,recommonmark,requests,setuptools,sh,shapely,tenacity,yaml,zstandard
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_training.py
+
33
−
43
View file @
f41589b5
# -*- coding: utf-8 -*-
# import json
import
os
from
pathlib
import
Path
import
responses
from
responses
import
matchers
from
arkindex.mock
import
MockApiClient
from
arkindex_worker.worker
import
BaseWorker
from
arkindex_worker.worker.training
import
TrainingMixin
,
create_archive
# import pytest
# import responses
# from responses import matchers
class
TrainingWorker
(
BaseWorker
,
TrainingMixin
):
def
__init__
(
self
):
...
...
@@ -26,7 +28,9 @@ def test_create_archive_folder():
):
assert
os
.
path
.
exists
(
zst_archive_path
),
"
The archive was not created
"
assert
(
hash
==
"
7dd70931222ef0496ea75e5aee674043
"
# hash == "7dd70931222ef0496ea75e5aee674043"
hash
==
"
c5aedde18a768757351068b840c8c8f9
"
),
"
Hash was not properly computed
"
assert
300
<
size
<
700
...
...
@@ -41,7 +45,7 @@ def test_create_model_version():
model_files_dir
=
Path
(
"
tests/samples/model_files
"
)
# model_file_path = model_files_dir / "model_file.pth"
training
=
TrainingWorker
()
client
=
MockApiClient
()
training
.
api_
client
=
MockApiClient
()
with
create_archive
(
path
=
model_files_dir
)
as
(
zst_archive_path
,
hash
,
...
...
@@ -58,35 +62,16 @@ def test_create_model_version():
"
s3_put_url
"
:
"
http://hehehe.com
"
,
}
client
.
__setattr__
(
"
model_version_details
"
,
model_version_details
)
responses
.
add
(
responses
.
POST
,
f
"
http://testserver/api/v1/model/
{
model_id
}
/versions/
"
,
status
=
200
,
match
=
[
matchers
.
json_params_matcher
(
{
"
hash
"
:
hash
,
"
archive_hash
"
:
archive_hash
,
"
size
"
:
size
}
)
],
json
=
model_version_details
,
response_mock
=
training
.
api_client
.
add_response
(
"
CreateModelVersion
"
,
response
=
model_version_details
,
body
=
{
"
hash
"
:
hash
,
"
archive_hash
"
:
archive_hash
,
"
size
"
:
size
},
)
print
(
model_version_details
)
# responses.add(
# responses.POST,
# f"http://testserver/api/v1/model/{model_id}/versions/",
# status=200,
# match=[
# matchers.json_params_matcher(
# {"hash": hash, "archive_hash": archive_hash, "size": size}
# )
# ],
# json=model_version_details,
# )
print
(
response_mock
)
assert
(
training
.
create_model_version
(
model_id
,
hash
,
size
,
archive_hash
)
==
model_version_details
==
response_mock
)
...
...
@@ -98,7 +83,8 @@ def test_create_model_version():
# model_version_id = "fake_model_version_id"
# # Create a model archive and keep its hash and size.
# model_file_path = samples_dir / "model_file.pth"
# training = TrainingMixin()
# training = TrainingWorker()
# training.api_client = MockApiClient()
# with create_archive(path=model_file_path) as (
# zst_archive_path,
# hash,
...
...
@@ -115,18 +101,22 @@ def test_create_model_version():
# "s3_put_url": "http://hehehe.com",
# }
# responses.add(
# responses.POST,
# f"http://testserver/api/v1/model/{model_id}/versions/",
# status=400,
# match=[
# matchers.json_params_matcher(
# {"hash": hash, "archive_hash": archive_hash, "size": size}
# )
# ],
# json={"hash": model_version_details},
# response_mock = training.api_client.add_response(
# )
# # responses.add(
# # responses.POST,
# # f"http://testserver/api/v1/model/{model_id}/versions/",
# # status=400,
# # match=[
# # matchers.json_params_matcher(
# # {"hash": hash, "archive_hash": archive_hash, "size": size}
# # )
# # ],
# # json={"hash": model_version_details},
# # )
# assert (
# training.create_model_version(api_client, model_id, hash, size, archive_hash)
# == model_version_details
...
...
@@ -138,7 +128,7 @@ def test_create_model_version():
# model_id = "fake_model_id"
# # Create a model archive and keep its hash and size.
# model_file_path = samples_dir / "model_file.pth"
# training = Training
Mixin
()
# training = Training
Worker
()
# with create_archive(path=model_file_path) as (
# zst_archive_path,
# hash,
...
...
@@ -165,6 +155,6 @@ def test_create_model_version():
# responses.add_passthru(s3_endpoint_url)
# responses.add(responses.Response(method="PUT", url=s3_endpoint_url, status=400))
# file_path = samples_dir / "model_file.pth"
# training = Training
Mixin
()
# training = Training
Worker
()
# with pytest.raises(Exception):
# training.upload_to_s3(file_path, {"s3_put_url": s3_endpoint_url})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment