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
b1c45187
Commit
b1c45187
authored
1 year ago
by
Ronald Jäpel
Browse files
Options
Downloads
Patches
Plain Diff
Improve handling of paths
parent
ea281620
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
+13
-7
13 additions, 7 deletions
cadetrdm/repositories.py
tests/test_git_adapter.py
+16
-9
16 additions, 9 deletions
tests/test_git_adapter.py
with
29 additions
and
16 deletions
cadetrdm/repositories.py
+
13
−
7
View file @
b1c45187
import
os
from
pathlib
import
Path
import
contextlib
import
glob
import
json
import
os
import
shutil
import
sys
import
traceback
from
datetime
import
datetime
import
shutil
import
time
import
contextlib
import
glob
from
pathlib
import
Path
from
stat
import
S_IREAD
,
S_IWRITE
from
urllib.request
import
urlretrieve
...
...
@@ -176,8 +175,12 @@ class BaseRepo:
:return:
Path to the cloned repository
"""
if
"
://
"
in
str
(
source_repo_location
):
source_repo_name
=
source_repo_location
.
split
(
"
/
"
)[
-
1
]
else
:
source_repo_name
=
Path
(
source_repo_location
).
name
if
target_repo_location
is
None
:
target_repo_location
=
self
.
working_dir
/
"
external_cache
"
/
source_repo_
location
.
split
(
"
/
"
)[
-
1
]
target_repo_location
=
self
.
working_dir
/
"
external_cache
"
/
source_repo_
name
else
:
target_repo_location
=
self
.
working_dir
/
target_repo_location
...
...
@@ -235,6 +238,9 @@ class BaseRepo:
target_repo_location
=
str
(
self
.
ensure_relative_path
(
target_repo_location
))
if
isinstance
(
source_repo_location
,
Path
):
source_repo_location
=
source_repo_location
.
as_posix
()
rdm_cache
[
target_repo_location
]
=
{
"
source_repo_location
"
:
source_repo_location
,
"
branch_name
"
:
source_repo_branch
,
...
...
This diff is collapsed.
Click to expand it.
tests/test_git_adapter.py
+
16
−
9
View file @
b1c45187
from
pathlib
import
Path
import
os
import
random
from
pathlib
import
Path
import
pytest
import
git
import
numpy
as
np
import
pytest
from
cadetrdm
import
initialize_repo
,
ProjectRepo
,
clone
from
cadetrdm.initialize_repo
import
init_lfs
from
cadetrdm.repositories
import
OutputRepo
,
BaseRepo
from
cadetrdm.io_utils
import
delete_path
from
cadetrdm.repositories
import
OutputRepo
,
BaseRepo
@pytest.fixture
(
scope
=
"
module
"
)
...
...
@@ -158,7 +158,7 @@ def test_init_over_existing_repo(monkeypatch):
def
test_cache_with_non_rdm_repo
(
monkeypatch
):
path_to_repo
=
Path
(
"
test
_repo
_5
"
)
path_to_repo
=
Path
(
"
non_rdm
_repo
"
)
if
path_to_repo
.
exists
():
delete_path
(
path_to_repo
)
os
.
makedirs
(
path_to_repo
)
...
...
@@ -172,15 +172,22 @@ def test_cache_with_non_rdm_repo(monkeypatch):
repo
.
git
.
add
(
"
.
"
)
repo
.
git
.
commit
(
"
-m
"
,
"
Initial commit
"
)
imported_repo
=
OutputRepo
(
"
../test_repo/results
"
)
branch_name
=
imported_repo
.
active_branch
.
name
os
.
chdir
(
"
..
"
)
if
Path
(
"
test_repo_non_rdm_imports
"
).
exists
():
delete_path
(
"
test_repo_non_rdm_imports
"
)
initialize_repo
(
"
test_repo_non_rdm_imports
"
)
os
.
chdir
(
"
test_repo_non_rdm_imports
"
)
repo
=
BaseRepo
(
"
.
"
)
if
Path
(
"
external_cache/non_rdm_repo
"
).
exists
():
delete_path
(
"
external_cache/non_rdm_repo
"
)
if
Path
(
"
foo/bar/non_rdm_repo
"
).
exists
():
delete_path
(
"
foo/bar/non_rdm_repo
"
)
# import two repos and confirm verify works.
repo
.
import_remote_repo
(
source_repo_location
=
"
..
/test_repo/results
"
,
source_repo_branch
=
branch_name
)
repo
.
import_remote_repo
(
source_repo_location
=
"
..
/test_repo/results
"
,
source_repo_branch
=
branch_name
,
target_repo_location
=
"
foo/bar/repo
"
)
repo
.
import_remote_repo
(
source_repo_location
=
"
..
"
/
path_to_repo
,
source_repo_branch
=
"
master
"
)
repo
.
import_remote_repo
(
source_repo_location
=
"
..
"
/
path_to_repo
,
source_repo_branch
=
"
master
"
,
target_repo_location
=
"
foo/bar/
non_rdm_
repo
"
)
repo
.
verify_unchanged_cache
()
...
...
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