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
26e02ac0
Commit
26e02ac0
authored
2 years ago
by
NolanB
Browse files
Options
Downloads
Patches
Plain Diff
Fix the error with the code review
parent
f67979ae
No related branches found
No related tags found
No related merge requests found
Pipeline
#79366
failed
2 years ago
Stage: test
Stage: build
Stage: release
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.isort.cfg
+1
-1
1 addition, 1 deletion
.isort.cfg
arkindex_worker/worker/training.py
+3
-8
3 additions, 8 deletions
arkindex_worker/worker/training.py
tests/test_elements_worker/test_training.py
+5
-6
5 additions, 6 deletions
tests/test_elements_worker/test_training.py
with
9 additions
and
15 deletions
.isort.cfg
+
1
−
1
View file @
26e02ac0
...
...
@@ -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,setuptools,sh,shapely,tenacity,yaml,zstandard
known_third_party
=
PIL,apistar,gitlab,gnupg,peewee,playhouse,pytest,recommonmark,requests,
responses,
setuptools,sh,shapely,tenacity,yaml,zstandard
This diff is collapsed.
Click to expand it.
arkindex_worker/worker/training.py
+
3
−
8
View file @
26e02ac0
...
...
@@ -6,11 +6,10 @@ import tempfile
from
contextlib
import
contextmanager
from
typing
import
NewType
,
Tuple
#
import requests
import
requests
import
zstandard
as
zstd
from
apistar.exceptions
import
ErrorResponse
from
arkindex
import
ArkindexClient
from
arkindex_worker
import
logger
CHUNK_SIZE
=
1024
...
...
@@ -87,7 +86,6 @@ class TrainingMixin(object):
):
# Create a new model version with hash and size
model_version_details
=
self
.
create_model_version
(
client
=
self
.
api_client
,
model_id
=
model_id
,
hash
=
hash
,
size
=
size
,
...
...
@@ -102,13 +100,11 @@ class TrainingMixin(object):
# Update the model version with state, configuration parsed, tag, description (defaults to name of the worker)
self
.
update_model_version
(
client
=
self
.
api_client
,
model_version_details
=
model_version_details
,
)
def
create_model_version
(
self
,
client
:
ArkindexClient
,
model_id
:
str
,
hash
:
str
,
size
:
int
,
...
...
@@ -116,7 +112,7 @@ class TrainingMixin(object):
)
->
dict
:
# Create a new model version with hash and size
try
:
model_version_details
=
client
.
request
(
model_version_details
=
self
.
request
(
"
CreateModelVersion
"
,
id
=
model_id
,
body
=
{
"
hash
"
:
hash
,
"
size
"
:
size
,
"
archive_hash
"
:
archive_hash
},
...
...
@@ -139,7 +135,7 @@ class TrainingMixin(object):
logger
.
info
(
"
Uploading to s3...
"
)
# Upload the archive on s3
with
open
(
archive_path
,
"
rb
"
)
as
archive
:
r
=
self
.
request
.
put
(
r
=
request
s
.
put
(
url
=
s3_put_url
,
data
=
archive
,
headers
=
{
"
Content-Type
"
:
"
application/zstd
"
},
...
...
@@ -155,7 +151,6 @@ class TrainingMixin(object):
)
->
None
:
logger
.
info
(
"
Updating the model version...
"
)
try
:
# request or requests ?
self
.
request
(
"
UpdateModelVersion
"
,
id
=
model_version_details
.
get
(
"
id
"
),
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_training.py
+
5
−
6
View file @
26e02ac0
from
http
import
client
import
imp
import
pytest
from
arkindex_worker.worker.training
import
create_archive
,
TrainingMixin
# -*- coding: utf-8 -*-
import
os
from
pathlib
import
Path
import
responses
from
responses
import
matchers
from
pathlib
import
Path
from
arkindex.mock
import
MockApiClient
from
arkindex_worker.worker.training
import
TrainingMixin
,
create_archive
def
test_create_archive_folder
():
model_file_dir
=
Path
(
"
tests/samples/model_files
"
)
...
...
@@ -141,7 +141,6 @@ def test_create_model_version():
# training.create_model_version(api_client, model_id, hash, size, archive_hash)
# def test_handle_s3_uploading_errors(samples_dir):
# s3_endpoint_url = "http://s3.localhost.com"
# responses.add_passthru(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