Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CADET-RDM
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IBG-1
ModSim
CADET
CADET-RDM
Commits
2a669032
Commit
2a669032
authored
1 year ago
by
Ronald Jäpel
Browse files
Options
Downloads
Patches
Plain Diff
Add: copy existing PROJECT code into OUTPUT repo on results commit
parent
5dbd80c5
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
cadetrdm/repositories.py
+23
-7
23 additions, 7 deletions
cadetrdm/repositories.py
tests/test_git_adapter.py
+3
-3
3 additions, 3 deletions
tests/test_git_adapter.py
with
26 additions
and
10 deletions
cadetrdm/repositories.py
+
23
−
7
View file @
2a669032
...
...
@@ -281,11 +281,11 @@ class ProjectRepo(BaseRepo):
super
().
__init__
(
repository_path
,
search_parent_directories
=
search_parent_directories
,
*
args
,
**
kwargs
)
if
output_folder
is
not
None
:
self
.
_
output_folder
=
output_folder
self
.
output_folder
=
output_folder
elif
output_folder
is
None
:
self
.
_
output_folder
=
"
output
"
self
.
output_folder
=
"
output
"
self
.
_output_repo
=
ResultsRepo
(
os
.
path
.
join
(
self
.
working_dir
,
self
.
_
output_folder
))
self
.
_output_repo
=
ResultsRepo
(
os
.
path
.
join
(
self
.
working_dir
,
self
.
output_folder
))
self
.
_on_context_enter_commit_hash
=
None
self
.
_is_in_context_manager
=
False
...
...
@@ -302,7 +302,7 @@ class ProjectRepo(BaseRepo):
"""
project_repo_hash
=
str
(
self
.
head
.
commit
)
timestamp
=
datetime
.
now
().
strftime
(
"
%Y-%m-%d-%H-%M-%S-%f
"
)[:
-
4
]
branch_name
=
"
_
"
.
join
([
str
(
self
.
active_branch
),
project_repo_hash
[:
7
],
self
.
_
output_folder
,
timestamp
])
branch_name
=
"
_
"
.
join
([
str
(
self
.
active_branch
),
project_repo_hash
[:
7
],
self
.
output_folder
,
timestamp
])
return
branch_name
def
check_results_master
(
self
):
...
...
@@ -330,7 +330,7 @@ class ProjectRepo(BaseRepo):
self
.
_output_repo
.
_git
.
checkout
(
"
master
"
)
logs_folderpath
=
os
.
path
.
join
(
self
.
working_dir
,
self
.
_
output_folder
,
"
logs
"
)
logs_folderpath
=
os
.
path
.
join
(
self
.
working_dir
,
self
.
output_folder
,
"
logs
"
)
if
not
os
.
path
.
exists
(
logs_folderpath
):
os
.
makedirs
(
logs_folderpath
)
...
...
@@ -366,12 +366,28 @@ class ProjectRepo(BaseRepo):
self
.
dump_package_list
(
logs_folderpath
)
code_copy_folderpath
=
os
.
path
.
join
(
logs_folderpath
,
"
code_backup
"
)
if
not
os
.
path
.
exists
(
code_copy_folderpath
):
os
.
makedirs
(
code_copy_folderpath
)
self
.
copy_code
(
code_copy_folderpath
)
self
.
_output_repo
.
add
(
"
.
"
)
self
.
_output_repo
.
_git
.
commit
(
"
-m
"
,
output_branch_name
)
self
.
_output_repo
.
_git
.
checkout
(
output_branch_name
)
self
.
_most_recent_branch
=
output_branch_name
def
copy_code
(
self
,
target_path
):
for
file
in
self
.
_git
.
ls_files
().
split
(
"
\n
"
):
target_file_path
=
os
.
path
.
join
(
self
.
working_dir
,
target_path
,
file
)
target_folder
=
os
.
path
.
split
(
target_file_path
)[
0
]
if
not
os
.
path
.
exists
(
target_folder
):
os
.
makedirs
(
target_folder
)
shutil
.
copyfile
(
os
.
path
.
join
(
self
.
working_dir
,
file
),
target_file_path
)
def
load_external_repository
(
self
,
url
,
branch
=
None
,
commit
=
None
,
name
=
None
,
path
=
None
,
):
"""
Load an external git repository as a git submodule into this repository.
...
...
@@ -449,8 +465,8 @@ class ProjectRepo(BaseRepo):
"""
Delete all previously cached results.
"""
if
os
.
path
.
exists
(
self
.
_
output_folder
+
"
_cached
"
):
shutil
.
rmtree
(
self
.
_
output_folder
+
"
_cached
"
)
if
os
.
path
.
exists
(
self
.
output_folder
+
"
_cached
"
):
shutil
.
rmtree
(
self
.
output_folder
+
"
_cached
"
)
def
enter_context
(
self
,
):
"""
...
...
This diff is collapsed.
Click to expand it.
tests/test_git_adapter.py
+
3
−
3
View file @
2a669032
...
...
@@ -104,7 +104,7 @@ def try_commit_results_data(path_to_repo):
repo
=
ProjectRepo
(
path_to_repo
)
current_commit_number
=
count_commit_number
(
repo
.
output_repo
)
with
repo
.
track_results
(
results_commit_message
=
"
Add array
"
):
example_generate_results_array
(
path_to_repo
,
output_folder
=
repo
.
_
output_folder
)
example_generate_results_array
(
path_to_repo
,
output_folder
=
repo
.
output_folder
)
updated_commit_number
=
count_commit_number
(
repo
.
output_repo
)
assert
current_commit_number
+
1
==
updated_commit_number
return
str
(
repo
.
output_repo
.
active_branch
)
...
...
@@ -115,7 +115,7 @@ def try_commit_results_with_uncommitted_code_changes(path_to_repo):
modify_code
(
path_to_repo
)
with
pytest
.
raises
(
Exception
):
with
repo
.
track_results
(
results_commit_message
=
"
Add array
"
):
example_generate_results_array
(
path_to_repo
,
output_folder
=
repo
.
_
output_folder
)
example_generate_results_array
(
path_to_repo
,
output_folder
=
repo
.
output_folder
)
repo
.
commit
(
"
add code to print random number
"
,
add_all
=
True
)
...
...
@@ -126,7 +126,7 @@ def try_load_previous_result(path_to_repo, branch_name):
file_path
=
"
result.csv
"
)
previous_array
=
np
.
loadtxt
(
cached_array_path
,
delimiter
=
"
,
"
)
extended_array
=
np
.
concatenate
([
previous_array
,
previous_array
])
extended_array_file_path
=
os
.
path
.
join
(
path_to_repo
,
repo
.
_
output_folder
,
"
extended_result.csv
"
)
extended_array_file_path
=
os
.
path
.
join
(
path_to_repo
,
repo
.
output_folder
,
"
extended_result.csv
"
)
np
.
savetxt
(
extended_array_file_path
,
extended_array
,
delimiter
=
"
,
"
)
...
...
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