Comments (4)
@mhuyck I've come up with the following function to do handle this issue. I wasn't able to add it as part of the __init__
function like I had originally thought I might because the DownloaderJob has to be saved before it can be saved as a foreign key to the DownloaderJobsToBatches table. Do you think this is about the best that can be done or do you know of any helpful tricks. (Maybe @rzelayafavila or @dongbohu might also have good input?)
@classmethod
def create_job_and_relationships(*args, **kwargs):
"""Inits and saves a job, its batches, and the relationships.
Creates and saves a single DownloaderJob. For each batch
passed in via the 'batches' keyword, saves that batch, creates
a DownloaderJobsToBatches record, and saves that record.
"""
batches = kwargs.pop('batches', None)
this_job = super().__init__(*args, **kwargs)
if batches is None:
raise KeyError("The 'batches' argument must be specified.")
else:
this_job.save()
for batch in batches:
batch.save()
downloader_job_to_batch = DownloaderJobsToBatches(batch=batch,
downloader_job=this_job)
downloader_job_to_batch.save()
return this_job
from refinebio.
👍
I don't know any special tricks for making __init__
do what we thought. It makes sense that you'd need to have the .save
done first so there's a bit of an initialization chicken and egg issue there.
My primary observation during that code review was that a one-line object initialization was getting replaced with a template-like block of code in a bunch of places, so if this helper function can streamline that you'll end up with more DRY code and all the bounty that comes with that.
from refinebio.
Yup I definitely feel that for sure.
from refinebio.
Addressed by #26
from refinebio.
Related Issues (20)
- Dataset Request GSE33463
- Dataset Request GSE135065
- Dataset Request GSE42825
- Dataset Request GSE1724
- Dataset Request GSE59019
- Dataset Request GSE100153
- Dataset Request GSE26296
- Dataset Request GSE74075
- Dataset Request GSE76925
- Dataset Request GSE42826
- Dataset Request GSE42832
- Dataset Request GSE45686
- Dataset Request GSE79786
- Dataset Request GSE103166
- Dataset Request GSE143303
- Dataset Request GSE13396
- Dataset Request GSE144338
- Dataset Request GSE13396
- Dataset Request GSE162635
- RDS CA Update
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refinebio.