Beracles commited on
Commit
3e648d1
·
1 Parent(s): e6d2f57

fix permission

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -1
  2. app/watermelon.py +8 -10
Dockerfile CHANGED
@@ -9,8 +9,9 @@ WORKDIR /code
9
  COPY ./requirements.txt /code/requirements.txt
10
 
11
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
- RUN mkdir /code/tmp
13
 
14
  COPY . .
15
 
 
 
16
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
9
  COPY ./requirements.txt /code/requirements.txt
10
 
11
  RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
12
 
13
  COPY . .
14
 
15
+ USER root
16
+
17
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
app/watermelon.py CHANGED
@@ -35,13 +35,11 @@ def submit(response: Response):
35
  timestamp = beijing().strftime("%Y%m%d_%H%M%S_%f")
36
  filename = timestamp+".jsonl"
37
  marker = timestamp+".submit"
38
- filepath_remote = "/".join([game, filename])
39
- markerpath_remote = "/".join([game, marker])
40
- filepath_local = "/".join(["tmp", filename])
41
- markerpath_local = "/".join(["tmp", marker])
42
  if not os.path.exists("tmp"):
43
  os.mkdir("tmp")
44
- with open(filepath_local, "w") as f:
45
  for key in train_generated:
46
  myobj = {
47
  "command": key,
@@ -50,18 +48,18 @@ def submit(response: Response):
50
  }
51
  json.dump(myobj, f, indent=None)
52
  f.write("\n")
53
- open(markerpath_local, "w").close()
54
  db_token = os.environ.get("db_token")
55
  try:
56
  hfapi.upload_file(
57
- path_or_fileobj=filepath_local,
58
- path_in_repo=filepath_remote,
59
  repo_id="pgsoft/features",
60
  repo_type="dataset",
61
  token=db_token)
62
  hfapi.upload_file(
63
- path_or_fileobj=markerpath_local,
64
- path_in_repo=markerpath_remote,
65
  repo_id="pgsoft/features",
66
  repo_type="dataset",
67
  token=db_token)
 
35
  timestamp = beijing().strftime("%Y%m%d_%H%M%S_%f")
36
  filename = timestamp+".jsonl"
37
  marker = timestamp+".submit"
38
+ filepath = "/".join([game, filename])
39
+ markerpath = "/".join([game, marker])
 
 
40
  if not os.path.exists("tmp"):
41
  os.mkdir("tmp")
42
+ with open(filepath, "w") as f:
43
  for key in train_generated:
44
  myobj = {
45
  "command": key,
 
48
  }
49
  json.dump(myobj, f, indent=None)
50
  f.write("\n")
51
+ open(markerpath, "w").close()
52
  db_token = os.environ.get("db_token")
53
  try:
54
  hfapi.upload_file(
55
+ path_or_fileobj=filepath,
56
+ path_in_repo=filepath,
57
  repo_id="pgsoft/features",
58
  repo_type="dataset",
59
  token=db_token)
60
  hfapi.upload_file(
61
+ path_or_fileobj=markerpath,
62
+ path_in_repo=markerpath,
63
  repo_id="pgsoft/features",
64
  repo_type="dataset",
65
  token=db_token)