-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28a14df
commit b7fe04c
Showing
7 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
venv/**/* | ||
venv | ||
tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
extend-ignore = E203 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
|
||
def create_sample_project( | ||
name: str, from_branch: str = "sample-project-basic" | ||
): # type: ignore | ||
if name == "": | ||
print("usage: python3.8 setup_sample_project.py <name> [from_branch]") | ||
return | ||
|
||
print("creating sample project $name from branch $from_branch") | ||
|
||
os.makedirs(f"tmp/{name}") | ||
os.chdir(f"tmp/{name}") | ||
subprocess.check_call( | ||
[ | ||
"git", | ||
"clone", | ||
"https://github.com/FactFiber/kedro-dvc.git", | ||
"-b", | ||
from_branch, | ||
".", | ||
] | ||
) | ||
# using virtualenv.create_environment no longer works | ||
subprocess.check_call(["virtualenv", f"env/{name}"]) | ||
activate_this_file = "env/test/bin/activate_this.py" | ||
exec( | ||
compile( | ||
open(activate_this_file, "rb").read(), activate_this_file, "exec" | ||
), | ||
dict(__file__=activate_this_file), | ||
) | ||
subprocess.check_call(["pip", "install", "--upgrade", "pip"]) | ||
subprocess.check_call(["pip", "install", "-r", "src/requirements.txt"]) | ||
# we should see kedro-dvc commands listed | ||
print(subprocess.check_output(["pip", "freeze"])) | ||
print('to use the sample project run "source env/$name/bin/activate"') | ||
|
||
|
||
if __name__ == "__main__": | ||
create_sample_project(name=sys.argv[1], from_branch=sys.argv[2]) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from tests.fixtures import * # noqa | ||
|
||
# pytest_plugins = ["fixtures"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
import subprocess | ||
|
||
import pytest | ||
|
||
from src.kedro_dvc.create_sample_project import create_sample_project | ||
|
||
|
||
def test_create_sample_project_success(): | ||
prev_dir: str = os.getcwd() | ||
name: str = "test" | ||
from_branch: str = "sample-project-basic" | ||
|
||
create_sample_project(name, from_branch) | ||
|
||
current_dir: str = os.getcwd() | ||
dirs = [d for d in os.listdir() if not os.path.isfile(d)] | ||
# pip.utils.get_installed_distributions() no longer exists | ||
freeze = subprocess.check_output(["pip", "freeze"]) | ||
pip_modules = [ | ||
i[i.find("\\n") + 2 :] for i in ("\\n" + str(freeze)[2:]).split("==") | ||
][:-1] | ||
|
||
assert prev_dir != current_dir | ||
assert current_dir.endswith(f"tmp/{name}") | ||
assert "env" in dirs | ||
assert "src" in dirs | ||
print(pip_modules) | ||
assert "wcwidth" in pip_modules | ||
|
||
|
||
def test_create_sample_project_no_name(): | ||
prev_dir: str = os.getcwd() | ||
name: str = "" | ||
from_branch: str = "sample-project-basic" | ||
|
||
create_sample_project(name, from_branch) | ||
|
||
current_dir: str = os.getcwd() | ||
|
||
assert prev_dir == current_dir | ||
|
||
|
||
def test_create_sample_project_nonexistant_branch(): | ||
name: str = "test" | ||
from_branch: str = "nonexistant-branch" | ||
with pytest.raises(Exception): | ||
create_sample_project(name, from_branch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# check info function of returned structs of each fixture | ||
# test correct working directory |