Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Test as a Service Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INS Courses
AutPy
Test as a Service Client
Merge requests
!2
Add some more debugging info and safeguards
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add some more debugging info and safeguards
safeguards
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Florian Bruhin
requested to merge
safeguards
into
master
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
Needs
taas!10 (merged)
(but should fail gracefully without it)
Edited
3 years ago
by
Florian Bruhin
0
0
Merge request reports
Viewing commit
e20bfdaf
Show latest version
1 file
+
13
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
e20bfdaf
Add some more debugging info and safeguards
· e20bfdaf
Florian Bruhin
authored
3 years ago
taas_client/cli.py
+
13
−
2
Options
from
logging
import
error
import
datetime
import
time
import
sys
from
click.termui
import
style
@@ -24,6 +25,13 @@ def upload_file(
),
url
:
str
=
typer
.
Argument
(
"
http://localhost:5000/testbook
"
,
envvar
=
"
TAAS_URL
"
),
):
if
not
notebook
.
is_relative_to
(
Path
.
home
()
/
'
work
'
/
'
AutPy
'
):
console
.
print
(
f
"
[red]Refusing to submit file from unexpected location[/]:
{
notebook
}
\n
"
"
Make sure you
'
re not accidentally working in the
'
Originale
'
folder!
"
)
raise
typer
.
Exit
(
code
=
1
)
modified
=
round
(
time
.
time
()
-
notebook
.
stat
().
st_mtime
)
sec
=
'
second
'
if
modified
==
1
else
'
seconds
'
suffix
=
'
, [red]make sure you saved![/]
'
if
modified
>=
10
else
''
@@ -66,12 +74,15 @@ def upload_file(
try
:
print
(
f
"
[red]Error:
{
exc
.
response
.
json
().
get
(
'
error
'
)
}
[/]
"
,
file
=
sys
.
stderr
)
print
(
f
"
[red]Message:
{
exc
.
response
.
json
().
get
(
'
msg
'
)
}
[/]
"
,
file
=
sys
.
stderr
)
print
(
"
:boom: [bold]Submission failed![/]
"
)
timestamp
=
datetime
.
datetime
.
now
().
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)
print
(
f
"
:boom: [bold]Submission failed![/] [bright_black](
{
timestamp
}
)[/]
"
)
except
:
pass
raise
typer
.
Exit
(
code
=
1
)
print
(
"
:mailbox: :heavy_check_mark: [bold]Submission successful![/]
"
)
commit
=
result
.
get
(
"
commit
"
,
"
?
"
)
timestamp
=
datetime
.
datetime
.
now
().
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)
print
(
f
"
:mailbox: :heavy_check_mark: [bold]Submission successful![/] [bright_black](
{
timestamp
}
,
{
commit
}
)[/]
"
)
def
run
():
Loading