MCPcopy Index your code
hub / github.com/diffgram/diffgram / update_dirs_to_job_api

Function update_dirs_to_job_api

default/methods/task/file/dir_attach.py:24–119  ·  view source on GitHub ↗

Method adds files to a job. Used in the job creation section when attaching files. Still need a method for individual file selection so start with this Adds selected files to a job Assumes the job already has a directory created For each file creates a pointer Assumptio

(project_string_id)

Source from the content-addressed store, hash-verified

22 Roles=["admin", "Editor"],
23 apis_user_list=['api_enabled_builder', 'security_email_verified'])
24def update_dirs_to_job_api(project_string_id):
25 """
26 Method adds files to a job. Used in the job creation section when attaching files.
27
28 Still need a method for individual file selection so start with this
29
30 Adds selected files to a job
31
32 Assumes the job already has a directory created
33
34 For each file creates a pointer
35
36 Assumption here is we are attaching files directly...
37 ie we don't have to check latest version or how that's happening...
38
39 Security for checking files are in directory...
40
41 """
42
43 # get / declare file list...
44
45 # Maybe instead of passing literal file list, we pass the search criteria?
46 # But limit of this is a user may select specific files...
47
48 # TODO a lot of this feels like generic stuff for
49 # Adding or removing to a directory
50
51 spec_list = [
52 {"directory_list":
53 {'kind': list, 'allow_empty': True}
54 },
55 {"job_id":
56 {'kind': int}
57 },
58 ]
59
60 log, input, untrusted_input = regular_input.master(request=request,
61 spec_list=spec_list)
62
63 if len(log["error"].keys()) >= 1:
64 return jsonify(log=log), 400
65
66 with sessionMaker.session_scope() as session:
67
68 project = Project.get(session, project_string_id)
69
70 job = Job.get_by_id(session, input['job_id'])
71
72 Job_permissions.check_job_after_project_already_valid(
73 job=job,
74 project=project)
75
76 directory_list = input['directory_list']
77 # Do nothing for emptry dir list.
78 if len(directory_list) == 0:
79 return jsonify(
80 log=log,
81 job=job.serialize_builder_info_edit(session)), 200

Callers

nothing calls this directly

Calls 8

set_cache_key_dirtyMethod · 0.80
getMethod · 0.45
get_by_idMethod · 0.45
addMethod · 0.45
newMethod · 0.45

Tested by

no test coverage detected