Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
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
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
Christoph Alt
cb-util
Commits
e13b29db
Commit
e13b29db
authored
2 years ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
job infos from all pages are now collected
parent
8edc4284
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#42924
passed
2 years ago
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cbutil/get_job_info.py
+12
-5
12 additions, 5 deletions
cbutil/get_job_info.py
cbutil/upload.py
+6
-5
6 additions, 5 deletions
cbutil/upload.py
cbutil/util.py
+1
-1
1 addition, 1 deletion
cbutil/util.py
with
19 additions
and
11 deletions
cbutil/get_job_info.py
+
12
−
5
View file @
e13b29db
...
...
@@ -26,11 +26,18 @@ def get_api_url_pipelines(base_url: str, project_id: int, pipeline_id: int):
def
get_job_info
(
url
:
str
):
jobs
=
requests
.
get
(
url
)
if
jobs
.
status_code
!=
200
:
jobs
.
raise_for_status
()
for
job
in
jobs
.
json
():
yield
job
next_url
=
url
while
True
:
logger
.
info
(
f
"
reqeuesting
{
next_url
}
"
)
jobs
=
requests
.
get
(
next_url
)
if
jobs
.
status_code
!=
200
:
jobs
.
raise_for_status
()
for
job
in
jobs
.
json
():
yield
job
if
(
next_page
:
=
jobs
.
headers
[
'
x-next-page
'
]):
next_url
=
f
"
{
url
}
?page=
{
next_page
}
"
else
:
break
def
create_job_datapoint
(
job
:
dict
)
->
DataPoint
:
...
...
This diff is collapsed.
Click to expand it.
cbutil/upload.py
+
6
−
5
View file @
e13b29db
import
os
import
logging
import
dotenv
import
os
import
pprint
from
influxdb
import
InfluxDBClient
from
dataclasses
import
dataclass
import
dotenv
from
influxdb
import
InfluxDBClient
logger
=
logging
.
getLogger
(
__file__
)
MISSING_DB_PW
=
"""
...
...
@@ -52,14 +53,14 @@ class Uploader:
database
=
config
.
database
,
)
def
upload
(
self
,
points
,
dry_run
=
False
,
*
args
,
**
kwargs
):
def
upload
(
self
,
points
,
dry_run
=
False
,
*
,
time_precision
=
'
s
'
,
**
kwargs
):
logger
.
info
(
f
"
Uploading:
{
pprint
.
pformat
(
points
)
}
"
)
if
(
common_tags
:
=
kwargs
.
get
(
"
tags
"
)):
logger
.
info
(
f
"
with common tags:
{
pprint
.
pformat
(
common_tags
)
}
"
)
if
not
dry_run
:
success
=
self
.
client
.
write_points
(
points
,
*
args
,
time_precision
=
time_precision
,
**
kwargs
)
if
success
:
logger
.
info
(
f
"
Uploaded
{
len
(
points
)
}
items
"
)
...
...
This diff is collapsed.
Click to expand it.
cbutil/util.py
+
1
−
1
View file @
e13b29db
...
...
@@ -56,7 +56,7 @@ def file_time_to_sec(file_path) -> int:
return
int
(
os
.
path
.
getmtime
(
file_path
))
def
time_conversion
(
time_stamp
,
*
,
pattern
=
"
%Y-%m-%d %H:%M:%S
%z
"
):
def
time_conversion
(
time_stamp
,
*
,
pattern
=
"
%Y-%m-%d %H:%M:%S
"
):
try
:
return
int
(
time_stamp
)
except
ValueError
as
e
:
...
...
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