Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
383ea6ab
"README.md" did not exist on "1dc24542d1a54021ca6595785b90bf708ee2dea4"
Commit
383ea6ab
authored
7 years ago
by
yvesn
Browse files
Options
Downloads
Patches
Plain Diff
obis: implemented init_analysis
parent
e0e8e156
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/python/OBis/obis/dm/data_mgmt.py
+10
-14
10 additions, 14 deletions
src/python/OBis/obis/dm/data_mgmt.py
src/python/OBis/obis/dm/git.py
+7
-0
7 additions, 0 deletions
src/python/OBis/obis/dm/git.py
src/python/OBis/obis/scripts/cli.py
+6
-6
6 additions, 6 deletions
src/python/OBis/obis/scripts/cli.py
with
23 additions
and
20 deletions
src/python/OBis/obis/dm/data_mgmt.py
+
10
−
14
View file @
383ea6ab
...
@@ -179,6 +179,9 @@ class GitDataMgmt(AbstractDataMgmt):
...
@@ -179,6 +179,9 @@ class GitDataMgmt(AbstractDataMgmt):
with
cd
(
path
):
with
cd
(
path
):
return
self
.
config_resolver
.
config_dict
().
get
(
'
data_set_id
'
)
return
self
.
config_resolver
.
config_dict
().
get
(
'
data_set_id
'
)
def
get_config
(
self
,
path
,
key
):
with
cd
(
path
):
return
self
.
config_resolver
.
config_dict
().
get
(
key
)
def
init_data
(
self
,
path
,
desc
=
None
,
create
=
True
,
apply_config
=
False
):
def
init_data
(
self
,
path
,
desc
=
None
,
create
=
True
,
apply_config
=
False
):
if
not
os
.
path
.
exists
(
path
)
and
create
:
if
not
os
.
path
.
exists
(
path
)
and
create
:
...
@@ -202,31 +205,24 @@ class GitDataMgmt(AbstractDataMgmt):
...
@@ -202,31 +205,24 @@ class GitDataMgmt(AbstractDataMgmt):
# get data_set_id of parent from current folder or explicit parent argument
# get data_set_id of parent from current folder or explicit parent argument
parent_folder
=
parent
if
parent
is
not
None
and
len
(
parent
)
>
0
else
"
.
"
parent_folder
=
parent
if
parent
is
not
None
and
len
(
parent
)
>
0
else
"
.
"
parent_data_set_id
=
self
.
get_data_set_id
(
parent_folder
)
parent_data_set_id
=
self
.
get_data_set_id
(
parent_folder
)
# check that
data_set_id is set -
parent repository has been added to openBIS
# check that parent repository has been added to openBIS
if
parent_data_set
_id
is
None
:
if
self
.
get_config
(
parent_folder
,
'
repository
_id
'
)
is
None
:
return
CommandResult
(
returncode
=-
1
,
output
=
"
Parent data set must be committed to openBIS before creating an analysis data set.
"
)
return
CommandResult
(
returncode
=-
1
,
output
=
"
Parent data set must be committed to openBIS before creating an analysis data set.
"
)
# check that analysis repository does not already exist
if
os
.
path
.
exists
(
path
):
return
CommandResult
(
returncode
=-
1
,
output
=
"
Data set already exists:
"
+
path
)
# init analysis repository
# init analysis repository
result
=
self
.
init_data
(
path
,
desc
,
create
,
apply_config
)
result
=
self
.
init_data
(
path
,
desc
,
create
,
apply_config
)
if
result
.
failure
():
if
result
.
failure
():
return
result
return
result
# add analysis repository folder to .gitignore of parent
# add analysis repository folder to .gitignore of parent
if
os
.
path
.
exists
(
'
.obis
'
):
if
os
.
path
.
exists
(
'
.obis
'
):
with
open
(
"
.gitignore
"
,
"
a
"
)
as
gitignore
:
self
.
git_wrapper
.
git_ignore
(
path
)
gitignore
.
write
(
path
)
gitignore
.
write
(
"
\n
"
)
elif
parent
is
None
:
elif
parent
is
None
:
return
CommandResult
(
returncode
=-
1
,
output
=
"
Not within a repository and no parent set.
"
)
return
CommandResult
(
returncode
=-
1
,
output
=
"
Not within a repository and no parent set.
"
)
# set data_set_id to analysis repository so it will be used as parent when committing
with
cd
(
path
):
with
cd
(
path
):
cli
.
config_internal
(
self
,
False
,
"
data_set_id
"
,
parent_data_set_id
)
cli
.
config_internal
(
self
,
False
,
"
data_set_id
"
,
parent_data_set_id
)
# TODO init repo and link new data set as child.
# add to gitignore of parent data set
# add parameter to reference parent in case it's not in the same folder
# TODO use git check-ignore to not add folder twice
# TODO cleanup when something goes wrong
return
result
return
result
...
...
This diff is collapsed.
Click to expand it.
src/python/OBis/obis/dm/git.py
+
7
−
0
View file @
383ea6ab
...
@@ -79,6 +79,13 @@ class GitWrapper(object):
...
@@ -79,6 +79,13 @@ class GitWrapper(object):
def
git_reset_to
(
self
,
commit_hash
):
def
git_reset_to
(
self
,
commit_hash
):
return
run_shell
([
self
.
git_path
,
'
reset
'
,
commit_hash
])
return
run_shell
([
self
.
git_path
,
'
reset
'
,
commit_hash
])
def
git_ignore
(
self
,
path
):
result
=
run_shell
([
self
.
git_path
,
'
check-ignore
'
,
path
])
if
result
.
returncode
==
1
:
with
open
(
"
.gitignore
"
,
"
a
"
)
as
gitignore
:
gitignore
.
write
(
path
)
gitignore
.
write
(
"
\n
"
)
class
GitRepoFileInfo
(
object
):
class
GitRepoFileInfo
(
object
):
"""
Class that gathers checksums and file lengths for all files in the repo.
"""
"""
Class that gathers checksums and file lengths for all files in the repo.
"""
...
...
This diff is collapsed.
Click to expand it.
src/python/OBis/obis/scripts/cli.py
+
6
−
6
View file @
383ea6ab
...
@@ -151,11 +151,11 @@ def init_data_impl(ctx, object_id, collection_id, folder, desc):
...
@@ -151,11 +151,11 @@ def init_data_impl(ctx, object_id, collection_id, folder, desc):
init_handle_cleanup
(
result
,
object_id
,
collection_id
)
init_handle_cleanup
(
result
,
object_id
,
collection_id
)
def
init_analysis_impl
(
ctx
,
object_id
,
collection_id
,
folder
,
parent
,
desc
):
def
init_analysis_impl
(
ctx
,
parent
,
object_id
,
collection_id
,
folder
,
description
):
click_echo
(
"
init_analysis {}
"
.
format
(
folder
))
click_echo
(
"
init_analysis {}
"
.
format
(
folder
))
data_mgmt
=
shared_data_mgmt
(
ctx
.
obj
)
data_mgmt
=
shared_data_mgmt
(
ctx
.
obj
)
desc
=
desc
if
desc
!=
""
else
None
desc
ription
=
description
if
desc
ription
!=
""
else
None
result
=
data_mgmt
.
init_analysis
(
folder
,
parent
,
desc
,
create
=
True
)
result
=
data_mgmt
.
init_analysis
(
folder
,
parent
,
desc
ription
,
create
=
True
)
init_handle_cleanup
(
result
,
object_id
,
collection_id
)
init_handle_cleanup
(
result
,
object_id
,
collection_id
)
...
@@ -193,14 +193,14 @@ def init_data(ctx, object_id, collection_id, folder, description):
...
@@ -193,14 +193,14 @@ def init_data(ctx, object_id, collection_id, folder, description):
@cli.command
()
@cli.command
()
@click.pass_context
@click.pass_context
@click.option
(
'
-p
'
,
'
--parent
'
,
type
=
click
.
Path
(
exists
=
False
,
file_okay
=
False
))
@click.option
(
'
-oi
'
,
'
--object_id
'
,
help
=
'
Set the id of the owning sample.
'
)
@click.option
(
'
-oi
'
,
'
--object_id
'
,
help
=
'
Set the id of the owning sample.
'
)
@click.option
(
'
-ci
'
,
'
--collection_id
'
,
help
=
'
Set the id of the owning experiment.
'
)
@click.option
(
'
-ci
'
,
'
--collection_id
'
,
help
=
'
Set the id of the owning experiment.
'
)
@click.argument
(
'
folder
'
,
type
=
click
.
Path
(
exists
=
False
,
file_okay
=
False
))
@click.argument
(
'
folder
'
,
type
=
click
.
Path
(
exists
=
False
,
file_okay
=
False
))
@click.argument
(
'
description
'
,
default
=
""
)
@click.argument
(
'
description
'
,
default
=
""
)
@click.option
(
'
-p
'
,
'
--parent
'
,
type
=
click
.
Path
(
exists
=
False
,
file_okay
=
False
))
def
init_analysis
(
ctx
,
parent
,
object_id
,
collection_id
,
folder
,
description
):
def
init_analysis
(
ctx
,
object_id
,
collection_id
,
folder
,
description
,
parent
):
"""
Initialize the folder as an analysis folder.
"""
"""
Initialize the folder as an analysis folder.
"""
return
init_analysis_impl
(
ctx
,
object_id
,
collection_id
,
folder
,
description
,
parent
)
return
init_analysis_impl
(
ctx
,
parent
,
object_id
,
collection_id
,
folder
,
description
)
@cli.command
()
@cli.command
()
...
...
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