Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
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
ssa
workspaces
Commits
ba518edb
Commit
ba518edb
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Added test for parse_setup.py; added some logging and error checking to transfer_to_builder.py
parent
cc7096b1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build/recipes/setup_to_meta/test/test_setup_to_meta.py
+13
-4
13 additions, 4 deletions
build/recipes/setup_to_meta/test/test_setup_to_meta.py
build/tools/transfer_to_builder.py
+28
-8
28 additions, 8 deletions
build/tools/transfer_to_builder.py
with
41 additions
and
12 deletions
build/recipes/setup_to_meta/test/test_setup_to_meta.py
+
13
−
4
View file @
ba518edb
...
...
@@ -3,32 +3,41 @@ from .. import setup_to_meta
class
TestSetupToMeta
:
def
test_del_substrings
(
self
):
"""
Test that del_substrings function properly deletes substrings from a given string
Test
s
that del_substrings function properly deletes substrings from a given string
"""
replaced
=
setup_to_meta
.
del_substrings
(
'
heallob, woarlcd
'
,
[
'
a
'
,
'
b
'
,
'
c
'
])
assert
replaced
==
'
hello, world
'
def
test_get_names
(
self
):
"""
Test that setup_to_meta correctly gets the package name from the package path
Test
s
that setup_to_meta correctly gets the package name from the package path
"""
d
=
'
apps/cli/executables/null
'
assert
setup_to_meta
.
get_names
([
d
])
==
[
'
null
'
]
def
test_get_dirs
(
self
):
"""
Test that setup_to_meta correctly finds and stores directory paths
Test
s
that setup_to_meta correctly finds and stores directory paths
of packages containing setup.py files
"""
assert
'
./apps/cli/executables/null
'
in
setup_to_meta
.
get_dirs
()
def
test_get_outputs
(
self
):
"""
Test
that test
s that setup_to_meta correctly generates a list of output paths given
Tests that setup_to_meta correctly generates a list of output paths given
a list of package names.
"""
assert
setup_to_meta
.
get_outputs
([
'
null
'
])
==
[
'
build/metadata/null/meta.yaml
'
]
def
test_parse_setup
(
self
):
"""
Tests that parse_setup correctly parses a setup.py file into a dictionary.
"""
setup_data
=
setup_to_meta
.
parse_setup
(
'
apps/cli/executables/null
'
)
keys
=
[
'
name
'
,
'
version
'
,
'
description
'
,
'
license
'
]
for
key
in
keys
:
assert
key
in
setup_data
def
test_output
(
self
,
recipe
):
"""
Test that metadata was successfully created and contains data.
...
...
This diff is collapsed.
Click to expand it.
build/tools/transfer_to_builder.py
+
28
−
8
View file @
ba518edb
import
subprocess
import
paramiko
import
logging
import
fnmatch
import
os
import
getpass
import
sys
import
os
from
scp
import
SCPClient
logger
=
logging
.
getLogger
(
"
buildtools/transfer_to_builder
"
)
logger
.
setLevel
(
logging
.
INFO
)
hander
=
logging
.
StreamHandler
(
stream
=
sys
.
stdout
)
def
get_build_pkg_names
():
"""
Search through pkgs directory for built .tar.bz2 packages
...
...
@@ -13,9 +19,12 @@ def get_build_pkg_names():
"""
pkg_names
=
[]
d
=
"
build/pkgs/noarch/
"
for
file
in
os
.
listdir
(
d
):
if
fnmatch
.
fnmatch
(
file
,
"
*.tar.bz2
"
):
pkg_names
.
append
(
d
+
file
)
try
:
for
file
in
os
.
listdir
(
d
):
if
fnmatch
.
fnmatch
(
file
,
"
*.tar.bz2
"
):
pkg_names
.
append
(
d
+
file
)
except
FileNotFoundError
as
e
:
logger
.
error
(
e
)
return
pkg_names
...
...
@@ -29,10 +38,18 @@ def create_ssh_client(server):
client
.
load_system_host_keys
()
client
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
username
=
input
(
"
Enter NRAO username:
"
)
password
=
getpass
.
getpass
(
prompt
=
"
Enter NRAO password:
"
)
while
True
:
username
=
input
(
"
Enter NRAO username:
"
)
password
=
getpass
.
getpass
(
prompt
=
"
Enter NRAO password:
"
)
try
:
client
.
connect
(
server
,
username
=
username
,
password
=
password
)
except
paramiko
.
AuthenticationException
as
e
:
logger
.
error
(
e
)
logger
.
error
(
"
Invalid credentials. Try again.
"
)
continue
break
client
.
connect
(
server
,
username
=
username
,
password
=
password
)
return
client
def
transfer_packages
(
pkg_names
):
...
...
@@ -40,6 +57,8 @@ def transfer_packages(pkg_names):
Use shell commands to transfer build archives to builder and update its conda package index.
:param pkg_names: Names of the .tar.bz2 files for the built packages.
"""
logger
.
addHandler
(
hander
)
if
len
(
pkg_names
):
builder_addr
=
"
builder.aoc.nrao.edu
"
builder_path
=
"
/home/builder.aoc.nrao.edu/content/conda/noarch
"
...
...
@@ -54,7 +73,8 @@ def transfer_packages(pkg_names):
cmd_index
+
"
&&
"
+
cmd_chmod
])
else
:
print
(
"
No packages found in build/pkgs/noarch. Did conda build successfully build the package(s)?
"
)
logger
.
error
(
"
No packages found in build/pkgs/noarch.
"
"
Did conda build successfully build the package(s)?
"
)
if
__name__
==
"
__main__
"
:
transfer_packages
(
get_build_pkg_names
())
\ No newline at end of file
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