Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
concepts-processing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
meldb
concepts-processing
Commits
66f7c9e9
Commit
66f7c9e9
authored
4 months ago
by
mjbonifa
Browse files
Options
Downloads
Patches
Plain Diff
tidied phen init
parent
dd623973
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
phen.py
+101
-96
101 additions, 96 deletions
phen.py
with
101 additions
and
96 deletions
phen.py
+
101
−
96
View file @
66f7c9e9
...
@@ -42,9 +42,12 @@ class PhenValidationException(Exception):
...
@@ -42,9 +42,12 @@ class PhenValidationException(Exception):
self
.
validation_errors
=
validation_errors
self
.
validation_errors
=
validation_errors
def
construct_git_url
(
remote_url
):
def
construct_git_url
(
remote_url
):
"""
Constructs a git url for github or gitlab including a PAT token environment variable
"""
# check the url
# check the url
parsed_url
=
urlparse
(
remote_url
)
parsed_url
=
urlparse
(
remote_url
)
# if github in the URL otherwise assume it's gitlab, if we want to use others such as codeberg we'd
# need to update this function if the URL scheme is different.
if
"
github.com
"
in
parsed_url
.
netloc
:
if
"
github.com
"
in
parsed_url
.
netloc
:
# get GitHub PAT from environment variable
# get GitHub PAT from environment variable
auth
=
os
.
getenv
(
"
ACMC_GITHUB_PAT
"
)
auth
=
os
.
getenv
(
"
ACMC_GITHUB_PAT
"
)
...
@@ -78,8 +81,11 @@ def init(phen_dir, remote_url):
...
@@ -78,8 +81,11 @@ def init(phen_dir, remote_url):
else
:
else
:
configure
=
True
configure
=
True
# configure phen directories
if
not
configure
:
if
configure
:
print
(
f
"
Exiting, phenotype not initiatised
"
)
return
# Initialise repo from local or remote
repo
=
None
repo
=
None
# if remote then clone the repo otherwise init a local repo
# if remote then clone the repo otherwise init a local repo
if
remote_url
!=
None
:
if
remote_url
!=
None
:
...
@@ -127,14 +133,18 @@ def init(phen_dir, remote_url):
...
@@ -127,14 +133,18 @@ def init(phen_dir, remote_url):
# if the phen path does not contain the config file then initialise the phen type
# if the phen path does not contain the config file then initialise the phen type
config_path
=
phen_path
/
CONFIG_FILE
config_path
=
phen_path
/
CONFIG_FILE
if
not
config_path
.
exists
():
if
config_path
.
exists
():
print
(
"
Creating configuration files
"
)
print
(
f
"
Phenotype configuration files already exist
"
)
return
print
(
"
Creating phen directory structure and config files
"
)
# create codes directory
# create codes directory
codes_path
=
phen_path
/
CODES_DIR
codes_path
=
phen_path
/
CODES_DIR
codes_path
.
mkdir
(
exist_ok
=
True
)
codes_path
.
mkdir
(
exist_ok
=
True
)
keep_path
=
codes_path
/
'
.gitkeep
'
keep_path
=
codes_path
/
'
.gitkeep
'
keep_path
.
touch
(
exist_ok
=
True
)
keep_path
.
touch
(
exist_ok
=
True
)
# create maps directory
# create concept sets directory
output_path
=
phen_path
/
OUTPUT_DIR
output_path
=
phen_path
/
OUTPUT_DIR
output_path
.
mkdir
(
exist_ok
=
True
)
output_path
.
mkdir
(
exist_ok
=
True
)
keep_path
=
output_path
/
'
.gitkeep
'
keep_path
=
output_path
/
'
.gitkeep
'
...
@@ -164,18 +174,13 @@ def init(phen_dir, remote_url):
...
@@ -164,18 +174,13 @@ def init(phen_dir, remote_url):
with
open
(
config_path
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
with
open
(
config_path
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
json
.
dump
(
config
,
f
,
indent
=
4
)
json
.
dump
(
config
,
f
,
indent
=
4
)
# add to repo and commit
# add to
git
repo and commit
repo
.
git
.
add
(
codes_path
)
repo
.
git
.
add
(
codes_path
)
repo
.
git
.
add
(
output_path
)
repo
.
git
.
add
(
output_path
)
repo
.
git
.
add
(
all
=
True
)
repo
.
git
.
add
(
all
=
True
)
msg
=
"
initialised the phen git repo.
"
repo
.
index
.
commit
(
"
initialised the phen git repo.
"
)
repo
.
index
.
commit
(
msg
)
print
(
msg
)
else
:
print
(
f
"
Phenotype configuration files already exist
"
)
print
(
f
"
Phenotype initialised
"
)
print
(
f
"
Phenotype initialised
"
)
else
:
print
(
f
"
Phenotype not initiatised
"
)
def
validate
(
phen_dir
):
def
validate
(
phen_dir
):
"""
Validates the phenotype directory is a git repo with standard structure
"""
"""
Validates the phenotype directory is a git repo with standard structure
"""
...
...
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