Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
embl_hpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Bio-IT Workshops
embl_hpc
Commits
abd42370
Commit
abd42370
authored
7 years ago
by
Mike Smith
Browse files
Options
Downloads
Patches
Plain Diff
updated code to print hostname
parent
84ea263b
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cluster_setup/hpc_example.py
+41
-0
41 additions, 0 deletions
cluster_setup/hpc_example.py
with
41 additions
and
0 deletions
cluster_setup/hpc_example.py
0 → 100755
+
41
−
0
View file @
abd42370
#!/usr/bin/python
import
sys
,
getopt
,
resource
,
time
,
platform
def
main
(
argv
):
wait_time
=
10
list_length
=
0
## handle the arguments
try
:
opts
,
args
=
getopt
.
getopt
(
argv
,
"
ht:l:
"
,[
"
time=
"
,
"
length=
"
])
except
getopt
.
GetoptError
as
err
:
print
str
(
err
)
print
'
python_example.py -t <wait time> -l <list length>
'
sys
.
exit
(
2
)
for
opt
,
arg
in
opts
:
if
opt
==
'
-h
'
:
print
'
python_example.py -t <wait time> -l <list length>
'
sys
.
exit
()
elif
opt
in
(
"
-t
"
,
"
--time
"
):
wait_time
=
max
(
10
,
float
(
arg
)
);
elif
opt
in
(
"
-l
"
,
"
--length
"
):
list_length
=
max
(
0
,
int
(
arg
)
)
print
'
Current host is:
'
,
platform
.
node
()
print
'
Wait time is:
'
,
wait_time
,
'
seconds
'
print
'
List length is:
'
,
list_length
## create a list of the required length
list
=
[]
for
i
in
range
(
0
,
list_length
):
list
.
append
(
1
)
## wait for the specified number of seconds
time
.
sleep
(
wait_time
)
## print the maximum memory usage to the screen
print
'
Memory usage:
'
,
resource
.
getrusage
(
resource
.
RUSAGE_SELF
).
ru_maxrss
/
1000.0
,
'
MB
'
if
__name__
==
"
__main__
"
:
main
(
sys
.
argv
[
1
:])
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