Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyIcat-Plus
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICAT
PyIcat-Plus
Merge requests
!24
Resolve "Add client to store information from archiving/restoration system"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add client to store information from archiving/restoration system"
4-client_archiving_restore_system
into
main
Overview
6
Commits
5
Pipelines
2
Changes
7
All threads resolved!
Hide all comments
Merged
Marjolaine Bodin
requested to merge
4-client_archiving_restore_system
into
main
2 years ago
Overview
6
Commits
5
Pipelines
2
Changes
7
All threads resolved!
Hide all comments
Expand
Closes
#4 (closed)
Edited
2 years ago
by
Marjolaine Bodin
0
0
Merge request reports
Compare
main
version 1
57328b4c
2 years ago
main (base)
and
latest version
latest version
c5d7ef6b
5 commits,
2 years ago
version 1
57328b4c
2 commits,
2 years ago
7 files
+
185
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
src/pyicat_plus/client/archive.py
0 → 100644
+
50
−
0
Options
import
json
from
enum
import
Enum
from
typing
import
Optional
from
.messaging
import
IcatMessagingClient
class
StatusType
(
Enum
):
ARCHIVING
=
"
archiving
"
RESTORATION
=
"
restoration
"
class
StatusLevel
(
Enum
):
INFO
=
"
info
"
WARNING
=
"
warning
"
ERROR
=
"
error
"
class
IcatArchiveStatusClient
:
"""
Client for storing archive and restoration status in ICAT.
"""
def
__init__
(
self
,
queue_urls
:
list
,
queue_name
:
str
=
"
icatArchiveRestoreStatus
"
,
monitor_port
:
Optional
[
int
]
=
None
,
timeout
:
Optional
[
float
]
=
None
,
):
self
.
_client
=
IcatMessagingClient
(
queue_urls
,
queue_name
,
monitor_port
=
monitor_port
,
timeout
=
timeout
)
def
send_archive_status
(
self
,
dataset_id
:
int
,
type
:
StatusType
,
level
:
StatusLevel
,
message
:
str
):
assert
dataset_id
,
"
ICAT requires the datasetId
"
assert
type
,
"
ICAT requires the type
"
assert
level
,
"
ICAT requires the level
"
root
=
{
"
datasetId
"
:
dataset_id
,
"
type
"
:
type
.
value
,
"
level
"
:
level
.
value
,
"
message
"
:
message
,
}
data
=
json
.
dumps
(
root
).
encode
(
"
utf-8
"
)
self
.
_client
.
send
(
data
)
def
check_health
(
self
):
"""
Raises an exception when not healthy
"""
self
.
_client
.
check_health
()
Loading