# Path: studio/payload_builders/payload_builder.py
# class PayloadBuilder:
#     """
#     Abstract class representing
#     payload object construction from experiment components.
#     Result is payload ready to be submitted for execution.
#     """
#     def __init__(self, name: str):
#         self.name = name if name else 'NO NAME'
# 
#     def construct(self, experiment, config, packages):
#         raise NotImplementedError(
#             'Not implemented for payload builder {0}'.format(self.name))
# 
# Path: studio/experiments/experiment.py
# class Experiment:
#     """Experiment information."""
# 
#     def __init__(self, key, filename, args, pythonenv,
#                  project=None,
#                  artifacts=None,
#                  status='waiting',
#                  resources_needed=None,
#                  time_added=None,
#                  time_started=None,
#                  time_last_checkpoint=None,
#                  time_finished=None,
#                  info=None,
#                  git=None,
#                  metric=None,
#                  pythonver=None,
#                  max_duration=None,
#                  owner=None,
#                  from_compl_service: bool = False):
#         if info is None:
#             info = {}
# 
#         self.key = key
#         self._build_args(filename, args)
#         self.owner = owner if owner else None
#         self.from_compl_service = from_compl_service
# 
#         self.pythonenv = pythonenv
#         self.project = project
#         self.pythonver = pythonver
#         if self.pythonver is None:
#             self.pythonver = "{0}.{1}"\
#                 .format(sys.version_info[0], sys.version_info[1])
# 
#         self._build_artifacts(key, artifacts)
# 
#         self.resources_needed = resources_needed
#         self.status = status
#         self.time_added = time_added
#         self.time_started = time_started
#         self.time_last_checkpoint = time_last_checkpoint
#         self.time_finished = time_finished
#         self.info = info
#         self.git = git
#         self.metric = metric
#         self.max_duration = max_duration
# 
#     def _build_args(self, filename, args):
#         self.args = []
#         self.filename = filename
# 
#         if filename and '::' in filename:
#             self.filename = '-m'
#             module_name = filename.replace('::', '.')
#             if module_name.startswith('.'):
#                 module_name = module_name[1:]
# 
#             self.args.append(module_name)
# 
#         if args:
#             self.args += args
# 
#         self.args = [shquote(a) for a in self.args]
# 
#     def _build_artifacts(self, key, artifacts):
#         if artifacts is not None:
#             for tag, art_dict in artifacts.items():
#                 if art_dict.get('mutable', False):
#                     art_dict['local'] = artifacts_tracker.get_artifact_cache(tag, key)
# 
#         # Build table of experiment artifacts:
#         self.artifacts = dict()
#         for tag, art in artifacts.items():
#             self.artifacts[tag] = Artifact(tag, art)
# 
#     def to_dict(self):
#         result = dict()
#         result['key'] = self.key
#         result['args'] = self.args
#         result['filename'] = self.filename
#         result['pythonenv'] = self.pythonenv
#         result['project'] = self.project
#         result['pythonver'] = self.pythonver
#         result['resources_needed'] = self.resources_needed
#         result['status'] = self.status
#         result['time_added'] = self.time_added
#         result['time_started'] = self.time_started
#         result['time_last_checkpoint'] = self.time_last_checkpoint
#         result['time_finished'] = self.time_finished
#         result['info'] = self.info
#         result['git'] = self.git
#         result['metric'] = self.metric
#         result['max_duration'] = self.max_duration
#         result['owner'] = self.owner
#         result['from_compl_service'] = self.from_compl_service
# 
#         # Process artifacts:
#         artifacts_dict = dict()
#         for art_name, art in self.artifacts.items():
#             artifacts_dict[art_name] = art.to_dict()
#         result['artifacts'] = artifacts_dict
#         return result


from studio.payload_builders.payload_builder import PayloadBuilder
from studio.experiments.experiment import Experiment

class UnencryptedPayloadBuilder(PayloadBuilder):
    """
    Simple payload builder constructing
    unencrypted experiment payloads.
    """

# Path: studio/payload_builders/payload_builder.py
# class PayloadBuilder:
#     """
#     Abstract class representing
#     payload object construction from experiment components.
#     Result is payload ready to be submitted for execution.
#     """
#     def __init__(self, name: str):
#         self.name = name if name else 'NO NAME'
# 
#     def construct(self, experiment, config, packages):
#         raise NotImplementedError(
#             'Not implemented for payload builder {0}'.format(self.name))
# 
# Path: studio/experiments/experiment.py
# class Experiment:
#     """Experiment information."""
# 
#     def __init__(self, key, filename, args, pythonenv,
#                  project=None,
#                  artifacts=None,
#                  status='waiting',
#                  resources_needed=None,
#                  time_added=None,
#                  time_started=None,
#                  time_last_checkpoint=None,
#                  time_finished=None,
#                  info=None,
#                  git=None,
#                  metric=None,
#                  pythonver=None,
#                  max_duration=None,
#                  owner=None,
#                  from_compl_service: bool = False):
#         if info is None:
#             info = {}
# 
#         self.key = key
#         self._build_args(filename, args)
#         self.owner = owner if owner else None
#         self.from_compl_service = from_compl_service
# 
#         self.pythonenv = pythonenv
#         self.project = project
#         self.pythonver = pythonver
#         if self.pythonver is None:
#             self.pythonver = "{0}.{1}"\
#                 .format(sys.version_info[0], sys.version_info[1])
# 
#         self._build_artifacts(key, artifacts)
# 
#         self.resources_needed = resources_needed
#         self.status = status
#         self.time_added = time_added
#         self.time_started = time_started
#         self.time_last_checkpoint = time_last_checkpoint
#         self.time_finished = time_finished
#         self.info = info
#         self.git = git
#         self.metric = metric
#         self.max_duration = max_duration
# 
#     def _build_args(self, filename, args):
#         self.args = []
#         self.filename = filename
# 
#         if filename and '::' in filename:
#             self.filename = '-m'
#             module_name = filename.replace('::', '.')
#             if module_name.startswith('.'):
#                 module_name = module_name[1:]
# 
#             self.args.append(module_name)
# 
#         if args:
#             self.args += args
# 
#         self.args = [shquote(a) for a in self.args]
# 
#     def _build_artifacts(self, key, artifacts):
#         if artifacts is not None:
#             for tag, art_dict in artifacts.items():
#                 if art_dict.get('mutable', False):
#                     art_dict['local'] = artifacts_tracker.get_artifact_cache(tag, key)
# 
#         # Build table of experiment artifacts:
#         self.artifacts = dict()
#         for tag, art in artifacts.items():
#             self.artifacts[tag] = Artifact(tag, art)
# 
#     def to_dict(self):
#         result = dict()
#         result['key'] = self.key
#         result['args'] = self.args
#         result['filename'] = self.filename
#         result['pythonenv'] = self.pythonenv
#         result['project'] = self.project
#         result['pythonver'] = self.pythonver
#         result['resources_needed'] = self.resources_needed
#         result['status'] = self.status
#         result['time_added'] = self.time_added
#         result['time_started'] = self.time_started
#         result['time_last_checkpoint'] = self.time_last_checkpoint
#         result['time_finished'] = self.time_finished
#         result['info'] = self.info
#         result['git'] = self.git
#         result['metric'] = self.metric
#         result['max_duration'] = self.max_duration
#         result['owner'] = self.owner
#         result['from_compl_service'] = self.from_compl_service
# 
#         # Process artifacts:
#         artifacts_dict = dict()
#         for art_name, art in self.artifacts.items():
#             artifacts_dict[art_name] = art.to_dict()
#         result['artifacts'] = artifacts_dict
#         return result


# Path: studio/payload_builders/unencrypted_payload_builder.py
from studio.payload_builders.payload_builder import PayloadBuilder
from studio.experiments.experiment import Experiment


class UnencryptedPayloadBuilder(PayloadBuilder):
    """
    Simple payload builder constructing
    unencrypted experiment payloads.
    """

    def construct(self, experiment: Experiment, config, packages):